Skip to content

Commit a321f92

Browse files
committed
spruce up linting workflow
1 parent 049310c commit a321f92

File tree

3 files changed

+51
-41
lines changed

3 files changed

+51
-41
lines changed

.codespellrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,17 @@ repos:
2020
rev: v2.4.1
2121
hooks:
2222
- id: codespell
23-
- repo: https://github.com/pycqa/isort
24-
rev: 6.0.1 # Use the latest stable version
23+
args: [--toml, pyproject.toml]
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.8.4
2526
hooks:
26-
- id: isort
27-
args:
28-
- --profile=black # Optional, makes isort compatible with Black
29-
- repo: https://github.com/psf/black
30-
rev: 25.1.0 # matching versions in pyproject.toml and github actions
31-
hooks:
32-
- id: black
33-
args: ["--check", "-v", "datajoint", "tests", "--diff"] # --required-version is conflicting with pre-commit
34-
- repo: https://github.com/PyCQA/flake8
35-
rev: 7.3.0
36-
hooks:
37-
# syntax tests
38-
- id: flake8
39-
args:
40-
- --select=E9,F63,F7,F82
41-
- --count
42-
- --show-source
43-
- --statistics
44-
files: datajoint # a lot of files in tests are not compliant
45-
# style tests
46-
- id: flake8
47-
args:
48-
- --ignore=E203,E722,W503
49-
- --count
50-
- --max-complexity=62
51-
- --max-line-length=127
52-
- --statistics
53-
- --per-file-ignores=datajoint/diagram.py:C901
54-
files: datajoint # a lot of files in tests are not compliant
27+
# Run the linter
28+
- id: ruff
29+
args: [--fix]
30+
files: ^(src/|tests/)
31+
# Run the formatter
32+
- id: ruff-format
33+
files: ^(src/|tests/)
5534
- repo: https://github.com/rhysd/actionlint
5635
rev: v1.7.7
5736
hooks:

pyproject.toml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,57 @@ test = [
8585
]
8686
dev = [
8787
"pre-commit",
88-
"black==24.2.0",
89-
"flake8",
90-
"isort",
88+
"ruff",
9189
"codespell",
9290
# including test
9391
"pytest",
9492
"pytest-cov",
9593
]
9694

97-
[tool.isort]
98-
profile = "black"
95+
[tool.ruff]
96+
# Equivalent to flake8 configuration
97+
line-length = 127
98+
target-version = "py39"
99+
100+
[tool.ruff.lint]
101+
# Enable specific rule sets equivalent to flake8 configuration
102+
select = [
103+
"E", # pycodestyle errors
104+
"W", # pycodestyle warnings
105+
"F", # pyflakes
106+
"C90", # mccabe complexity
107+
]
108+
109+
# Ignore specific rules (equivalent to flake8 --ignore)
110+
ignore = [
111+
"E203", # whitespace before ':'
112+
"E722", # bare except
113+
]
114+
115+
# Per-file ignores (equivalent to flake8 --per-file-ignores)
116+
[tool.ruff.lint.per-file-ignores]
117+
"datajoint/diagram.py" = ["C901"] # function too complex
118+
119+
[tool.ruff.lint.mccabe]
120+
# Maximum complexity (equivalent to flake8 --max-complexity)
121+
max-complexity = 62
122+
123+
[tool.ruff.format]
124+
# Use black-compatible formatting
125+
quote-style = "double"
126+
indent-style = "space"
127+
line-ending = "auto"
99128

100129
[tool.setuptools]
101130
packages = ["datajoint"]
102131
package-dir = {"" = "src"}
103132

104133
[tool.setuptools.dynamic]
105134
version = { attr = "datajoint.version.__version__"}
135+
136+
[tool.codespell]
137+
skip = ".git,*.pdf,*.svg,*.csv,*.ipynb,*.drawio"
138+
# Rever -- nobody knows
139+
# numer -- numerator variable
140+
# astroid -- Python library name (not "asteroid")
141+
ignore-words-list = "rever,numer,astroid"

0 commit comments

Comments
 (0)