Skip to content

Commit d280359

Browse files
authored
Merge pull request #2 from alan-turing-institute/update-pre-commit-ci-and-config
Update pre-commit CI and config
2 parents 806ba1f + 45161dc commit d280359

5 files changed

Lines changed: 71 additions & 9 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ jobs:
4848
run: |
4949
uv sync --extra dev
5050
51+
- name: Run pre-commit
52+
run: |
53+
uv run pre-commit run --hook-stage manual --all-files
54+
5155
- name: Test with pytest
5256
run: |
5357
# stop pytest after 3 failures to save CI time

.pre-commit-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ repos:
1111
- id: ruff-format
1212
types_or: [ python, pyi ]
1313
- repo: https://github.com/RobertCraigie/pyright-python
14-
rev: v1.1.405
14+
rev: v1.1.407
1515
hooks:
1616
- id: pyright
17-
# - repo: https://github.com/kyanan/nbstripout
18-
# rev: 0.8.1
19-
# hooks:
20-
# - id: nbstripout
21-
# exclude: ^case_studies/
17+
- repo: https://github.com/kynan/nbstripout
18+
rev: 0.8.1
19+
hooks:
20+
- id: nbstripout

pyproject.toml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dev = [
1515
"pytest>=9.0.1",
1616
"pytest-cov>=7.0.0",
1717
"ruff==0.14.4",
18-
"pyright==1.1.405",
18+
"pyright==1.1.407",
1919
"pre-commit>=4.4.0",
2020
]
2121

@@ -25,3 +25,62 @@ auto-x = "auto_x:main"
2525
[build-system]
2626
requires = ["uv_build>=0.8.15,<0.9.0"]
2727
build-backend = "uv_build"
28+
29+
[tool.pyright]
30+
venvPath = "."
31+
venv = ".venv"
32+
33+
[tool.ruff]
34+
line-length = 88
35+
target-version = "py310"
36+
37+
[tool.ruff.format]
38+
docstring-code-format = true
39+
40+
[tool.ruff.lint]
41+
select = [
42+
"D", # docstring conventions
43+
"E",
44+
"F",
45+
"W", # flake8
46+
"B", # flake8-bugbear
47+
"I", # isort
48+
"ARG", # flake8-unused-arguments
49+
"C4", # flake8-comprehensions
50+
"EM", # flake8-errmsg
51+
"ICN", # flake8-import-conventions
52+
"ISC", # flake8-implicit-str-concat
53+
"G", # flake8-logging-format
54+
"PGH", # pygrep-hooks
55+
"PIE", # flake8-pie
56+
"PL", # pylint
57+
"PT", # flake8-pytest-style
58+
"RET", # flake8-return
59+
"RUF", # Ruff-specific
60+
"SIM", # flake8-simplify
61+
"UP", # pyupgrade
62+
"YTT", # flake8-2020
63+
"EXE", # flake8-executable
64+
]
65+
66+
ignore = [
67+
"PLR2004", # Magic value used in comparison
68+
"EM102", # Exception must not use an f-string literal, assign to variable first
69+
"ISC001", # Conflicts with formatter
70+
# "D417", # Missing trailing new line in docstring
71+
"D100", # Missing docstring in public module
72+
"D104", # Missing docstring in public package
73+
"PLR0913", # too many arguments
74+
]
75+
76+
unfixable = [
77+
"F401", # Would remove unused imports
78+
"F841", # Would remove unused variables
79+
]
80+
flake8-unused-arguments.ignore-variadic-names = true # allow unused *args/**kwargs
81+
82+
[tool.ruff.lint.pydocstyle]
83+
convention = "numpy"
84+
85+
[tool.ruff.lint.per-file-ignores]
86+
"tests/*.py" = ["D"]

src/auto_x/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
def main() -> None:
1+
def main() -> None: # noqa: D103
22
print("Hello from auto-x!")

tests/test_imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def test_imports():
2-
import auto_x # noqa: F401
2+
import auto_x # noqa: F401, PLC0415

0 commit comments

Comments
 (0)