Skip to content

Commit

Permalink
IN-894 Update project configuration and linting defaults
Browse files Browse the repository at this point in the history
Why these changes are being introduced:
* Simplify and harmonize project configuration and linting methods
with modern and active libraries that augment one another.

How this addresses that need:
* Add new files based on our Python project templates:
   * Makefile
   * pyproject.toml
   * .pre-commit-config.yaml
* Update Pipfile to include default depdendencies for 'dev-packages'
* Update Pipfile to install 'psycopg2-binary'
* Update dependencies

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-894
  • Loading branch information
jonavellecuerdo committed Nov 16, 2023
1 parent b34f77b commit d82ebb8
Show file tree
Hide file tree
Showing 5 changed files with 1,138 additions and 595 deletions.
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
default_language_version:
python: python3.11
repos:
- repo: local
hooks:
- id: black-apply
name: black-apply
entry: pipenv run black
language: system
pass_filenames: true
types: ["python"]
- id: mypy
name: mypy
entry: pipenv run mypy
language: system
pass_filenames: true
types: ["python"]
exclude: "tests/"
- id: ruff-apply
name: ruff-apply
entry: pipenv run ruff check --fix
language: system
pass_filenames: true
types: ["python"]
- id: safety
name: safety
entry: pipenv check
language: system
pass_filenames: false
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SHELL=/bin/bash
DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ)

## ---- Dependency commands ---- ##

install: # install dependencies
pipenv install --dev
pipenv run pre-commit install

update: install # update all Python dependencies
pipenv clean
pipenv update --dev

## ---- Unit test commands ---- ##

test: # run tests and print a coverage report
pipenv run coverage run --source=my_app -m pytest -vv
pipenv run coverage report -m

coveralls: test
pipenv run coverage lcov -o ./coverage/lcov.info


## ---- Code quality and safety commands ---- ##

# linting commands
lint: black mypy ruff safety

black:
pipenv run black --check --diff .

mypy:
pipenv run mypy .

ruff:
pipenv run ruff check .

safety:
pipenv check
pipenv verify

# apply changes to resolve any linting errors
lint-apply: black-apply ruff-apply

black-apply:
pipenv run black .

ruff-apply:
pipenv run ruff check --fix .
14 changes: 9 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ verify_ssl = true
name = "pypi"

[requires]
python_version = "3.9"
python_version = "3.11"

[dev-packages]
black = "*"
coveralls = "*"
freezegun = "*"
pytest-cov = "*"
mypy = "*"
pre-commit = "*"
pytest = "*"
pytest-django = "*"
requests-mock = "*"
ruff = "*"
#pytest-cov = "*"
#requests-mock = "*"

[packages]
# Only needed for Heroku
Expand All @@ -31,7 +35,7 @@ django-libsass = "*"
gunicorn = "*"
newrelic = "*"
Pillow = "*"
psycopg2 = "*"
psycopg2-binary = "*"
python-dotenv = "*"
pyyaml = "*"
redis = "*"
Expand Down
Loading

0 comments on commit d82ebb8

Please sign in to comment.