Skip to content

Commit e09512f

Browse files
committed
Update Makefile, pre-commit, linting, and dependency conventions
Why these changes are being introduced: These changes encapsulate some discussions to update some devops conventions that operate at the intersection of the Makefile, pre-commit hooks, linting, and dependency handling. These changes were prompted by a critical mass of some structure creep over time, and some feedback of unhelpful friction in some areas. How this addresses that need: * linting section reworked in Makefile * pre-commit fires only on git push * pre-commit no longer runs commands that modify code * `ruff format` is used in place of `black` * vulernability scanning moved to `make security` * security scanning removed from linting and pre-commit hooks Side effects of this change: * Vulnerability scanning is an ad-hoc decision by developers in the short-term, with notifications in Github via dependabot. Longer term, we will rely on renovate for rolling dependency updates. * Local commits are no longer constrained by pre-commit hooks, but hooks are enforced when pushing to Github. * We move further into the ecosystem of astral's ruff library, using the built-in formatter instead of black. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1676
1 parent 12415eb commit e09512f

File tree

4 files changed

+255
-272
lines changed

4 files changed

+255
-272
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
default_language_version:
22
python: python3.12
3+
default_stages:
4+
- pre-push
35
repos:
46
- repo: local
57
hooks:
6-
- id: black-apply
7-
name: black-apply
8-
entry: uv run black
8+
- id: ruff-format
9+
name: ruff-format
10+
entry: uv run ruff format --diff
911
language: system
1012
pass_filenames: true
11-
types: ["python"]
13+
types: [ "python" ]
14+
1215
- id: mypy
1316
name: mypy
1417
entry: uv run mypy
1518
language: system
1619
pass_filenames: true
17-
types: ["python"]
18-
exclude: "tests/"
19-
- id: ruff-apply
20-
name: ruff-apply
21-
entry: uv run ruff check --fix
20+
types: [ "python" ]
21+
exclude: "(tests/|output/|migrations/)"
22+
23+
- id: ruff-check
24+
name: ruff-check
25+
entry: uv run ruff check
2226
language: system
2327
pass_filenames: true
24-
types: ["python"]
25-
- id: pip-audit
26-
name: pip-audit
27-
entry: uv run pip-audit
28-
language: system
29-
pass_filenames: false
28+
types: [ "python" ]

Makefile

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ install: .venv .git/hooks/pre-commit # Install Python dependencies and create vi
2121

2222
.git/hooks/pre-commit: # Sets up pre-commit hook if not setup
2323
@echo "Installing pre-commit hooks..."
24-
uv run pre-commit install
24+
pre-commit install --hook-type pre-push --hook-type pre-commit
2525

2626
venv: .venv # Create the Python virtual environment
2727

@@ -41,31 +41,21 @@ coveralls: test # Write coverage data to an LCOV report
4141
uv run coverage lcov -o ./coverage/lcov.info
4242

4343
####################################
44-
# Code quality and safety commands
44+
# Code linting and formatting
4545
####################################
4646

47-
lint: black mypy ruff safety # Run linters
48-
49-
black: # Run 'black' linter and print a preview of suggested changes
50-
uv run black --check --diff .
51-
52-
mypy: # Run 'mypy' linter
47+
lint: # Run linting, alerts only, no code changes
48+
uv run ruff format --diff
5349
uv run mypy .
54-
55-
ruff: # Run 'ruff' linter and print a preview of errors
5650
uv run ruff check .
5751

58-
safety: # Check for security vulnerabilities
59-
uv run pip-audit
60-
61-
lint-apply: black-apply ruff-apply # Apply changes with 'black' and resolve 'fixable errors' with 'ruff'
62-
63-
black-apply: # Apply changes with 'black'
64-
uv run black .
65-
66-
ruff-apply: # Resolve 'fixable errors' with 'ruff'
52+
lint-fix: # Run linting, auto fix behaviors where supported
53+
uv run ruff format .
6754
uv run ruff check --fix .
6855

56+
security: # Run security / vulnerability checks
57+
uv run pip-audit
58+
6959
##############################
7060
# CLI convenience commands
7161
##############################

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ dependencies = [
1414

1515
[dependency-groups]
1616
dev = [
17-
"black>=25.1.0",
1817
"coveralls>=4.0.1",
1918
"mypy>=1.17.1",
2019
"pip-audit>=2.9.0",

0 commit comments

Comments
 (0)