Skip to content

Commit 18583fc

Browse files
Merge pull request #7 from MITLibraries/IN-894-update-config-and-linting-defaults
In 894 update config and linting defaults
2 parents 9c4e1d2 + ec9cd08 commit 18583fc

File tree

13 files changed

+805
-51
lines changed

13 files changed

+805
-51
lines changed

.dockerignore

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
coverage/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# poetry
99+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100+
# This is especially recommended for binary packages to ensure reproducibility, and is more
101+
# commonly ignored for libraries.
102+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103+
#poetry.lock
104+
105+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
106+
__pypackages__/
107+
108+
# Celery stuff
109+
celerybeat-schedule
110+
celerybeat.pid
111+
112+
# SageMath parsed files
113+
*.sage.py
114+
115+
# Environments
116+
.env
117+
.venv
118+
env/
119+
venv/
120+
ENV/
121+
env.bak/
122+
venv.bak/
123+
124+
# Spyder project settings
125+
.spyderproject
126+
.spyproject
127+
128+
# Rope project settings
129+
.ropeproject
130+
131+
# mkdocs documentation
132+
/site
133+
134+
# mypy
135+
.mypy_cache/
136+
.dmypy.json
137+
dmypy.json
138+
139+
# Pyre type checker
140+
.pyre/
141+
142+
# pytype static type analyzer
143+
.pytype/
144+
145+
# Cython debug symbols
146+
cython_debug/
147+
148+
# IDEs
149+
.idea/
150+
.vscode/
151+
152+
# Local directories
153+
output/
154+
155+
# MacOS files
156+
.DS_Store
157+
158+

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
default_language_version:
2+
python: python3.11 # set for project python version
3+
repos:
4+
- repo: local
5+
hooks:
6+
- id: black-apply
7+
name: black-apply
8+
entry: pipenv run black
9+
language: system
10+
pass_filenames: true
11+
types: ["python"]
12+
- id: mypy
13+
name: mypy
14+
entry: pipenv run mypy
15+
language: system
16+
pass_filenames: true
17+
types: ["python"]
18+
exclude: "tests/"
19+
- id: ruff-apply
20+
name: ruff-apply
21+
entry: pipenv run ruff check --fix
22+
language: system
23+
pass_filenames: true
24+
types: ["python"]
25+
- id: safety
26+
name: safety
27+
entry: pipenv check
28+
language: system
29+
pass_filenames: false

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.10.3
1+
3.11.4

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-slim as build
1+
FROM python:3.11-slim as build
22
WORKDIR /app
33
COPY . .
44

Makefile

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
11
SHELL=/bin/bash
22
DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ)
33

4-
### Dependency commands ###
4+
## ---- Dependency commands ---- ##
55

6-
install: ## Install dependencies and CLI app
6+
install: # install dependencies
77
pipenv install --dev
8+
pipenv run pre-commit install
89

9-
update: install ## Update all Python dependencies
10+
update: install # update all Python dependencies
1011
pipenv clean
1112
pipenv update --dev
1213

13-
### Test commands ###
14+
## ---- Unit test commands ---- ##
1415

15-
test: ## Run tests and print a coverage report
16+
test: # run tests and print a coverage report
1617
pipenv run coverage run --source=my_app -m pytest -vv
1718
pipenv run coverage report -m
1819

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

22-
### Code quality and safety commands ###
2323

24-
lint: bandit black mypy pylama safety ## Run linting, code quality, and safety checks
24+
## ---- Code quality and safety commands ---- ##
2525

26-
bandit:
27-
pipenv run bandit -r my_app
26+
# linting commands
27+
lint: black mypy ruff safety
2828

2929
black:
3030
pipenv run black --check --diff .
3131

3232
mypy:
33-
pipenv run mypy my_app
33+
pipenv run mypy .
3434

35-
pylama:
36-
pipenv run pylama --options setup.cfg
35+
ruff:
36+
pipenv run ruff check .
3737

3838
safety:
3939
pipenv check
4040
pipenv verify
41+
42+
# apply changes to resolve any linting errors
43+
lint-apply: black-apply ruff-apply
44+
45+
black-apply:
46+
pipenv run black .
47+
48+
ruff-apply:
49+
pipenv run ruff check --fix .

Pipfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ click = "*"
88
sentry-sdk = "*"
99

1010
[dev-packages]
11-
bandit = "*"
1211
black = "*"
13-
coverage = "*"
1412
coveralls = "*"
1513
mypy = "*"
16-
pylama = {extras = ["all"], version = "*"}
14+
pre-commit = "*"
1715
pytest = "*"
16+
ruff = "*"
1817

1918
[requires]
20-
python_version = "3.10"
19+
python_version = "3.11"
2120

2221
[scripts]
2322
my_app = "python -c \"from my_app.cli import main; main()\""

0 commit comments

Comments
 (0)