Skip to content

Commit 31f4f29

Browse files
Takishimaclaude
andauthored
Modernize ruff configuration to follow latest guidelines (#135)
* Modernize ruff configuration to follow latest guidelines - Remove target-version (now inferred from requires-python) - Replace TCH with TC (renamed rule set) - Remove ASYNC1 (merged into ASYNC) - Remove deprecated/removed rules from ignore: ANN101, E111, E114, E117, W191 - Remove duplicate S603 and unused COM812/COM819 from ignore - Add new rule sets: DOC (pydoclint), PYI (flake8-pyi), PD (pandas-vet) - Move LOG rule to alphabetical order - Remove deprecated flake8-annotations options: mypy-init-return, suppress-none-returning - Add DOC to per-file-ignores for tests - Fix typo: "rulues" -> "rules" in comment * Add additional ruff ignores and remove unused blacken-docs - Add ANN204, DOC201, DOC501 to global ignore list (too strict for codebase) - Add PYI024 to test file ignores - Fix DOC102: remove documented param 'namespace' not in function signature - Remove blacken-docs hook (no Python code blocks in documentation) * Add blacken-docs with ruff as formatter Configure blacken-docs to use ruff instead of black for formatting Python code blocks in documentation files. * Add changelog entry for ruff configuration modernization --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2015b51 commit 31f4f29

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ repos:
5151
- id: yamllint
5252

5353
- repo: https://github.com/asottile/blacken-docs
54-
rev: 1.20.0
54+
rev: 1.19.1
5555
hooks:
5656
- id: blacken-docs
57-
args: [-S, -l, '120']
58-
additional_dependencies: [black==22.12.0]
57+
args: [--line-length=120]
58+
additional_dependencies: [ruff>=0.14.0]
5959

6060
- repo: https://github.com/astral-sh/ruff-pre-commit
6161
rev: v0.14.10

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
### Repository
2121

2222
- Fixed Windows CI by using pip to install cppcheck (Chocolatey package is broken)
23+
- Modernize ruff configuration to follow latest guidelines
24+
- Remove deprecated settings (`target-version`, `ANN101`, `ASYNC1`, etc.)
25+
- Replace `TCH` with `TC` (renamed rule set)
26+
- Add new rule sets: `DOC`, `PYI`, `PD`
27+
- Configure `blacken-docs` to use ruff instead of black
2328

2429
- Clarify where to put the settings in `pyproject.toml`
2530
- Update GitHub Action `actions/download-artifact` to v4
@@ -33,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3338
- Update `github.com/codespell-project/codespell` hook to v2.4.1
3439
- Update `github.com/shellcheck-py/shellcheck-py` hook to v0.11.0.1
3540
- Update `github.com/adrienverge/yamllint.git` hook to v1.37.1
36-
- Update `github.com/asottile/blacken-docs` hook to 1.20.0
41+
- Update `github.com/asottile/blacken-docs` hook to 1.19.1
3742
- Update `github.com/astral-sh/ruff-pre-commit` hook to v0.14.10
3843

3944
## [v1.9.6] - 2024-06-02

cmake_pc_hooks/_argparse.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def _load_data_from_toml(
126126
elements (ie. no nested sections).
127127
128128
Args:
129-
namespace: Namespace to store results into
130129
path: Path to TOML file
131130
section: Name of section to load in TOML file
132131
path_must_exist: Whether a missing TOML file is considered an error or not

pyproject.toml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ namespaces = false
6565

6666
[tool.ruff]
6767
line-length = 120
68-
target-version = 'py310'
6968

7069
[tool.ruff.lint]
7170

@@ -77,10 +76,9 @@ select = ['F', # pyflakes
7776
'N', # pep8-naming
7877
'D', # pydocstyle
7978
'UP', # pyupgrade
80-
'YTT', # flake-2020
79+
'YTT', # flake8-2020
8180
'ANN', # flake8-annotations
8281
'ASYNC', # flake8-async
83-
'ASYNC1', # flake8-trio
8482
'S', # flake8-bandit
8583
'BLE', # flake8-blind-except
8684
'FBT', # flake8-boolean-trap
@@ -94,8 +92,10 @@ select = ['F', # pyflakes
9492
'FA', # flake8-future-annotations
9593
'ISC', # flake8-implicit-str-concat
9694
'ICN', # flake8-import-conventions
95+
'LOG', # flake8-logging
9796
'G', # flake8-logging-format
9897
'PIE', # flake8-pie
98+
'PYI', # flake8-pyi
9999
'PT', # flake8-pytest-style
100100
'Q', # flake8-quotes
101101
'RSE', # flake8-raise
@@ -104,43 +104,39 @@ select = ['F', # pyflakes
104104
'SLOT', # flake8-slots
105105
'SIM', # flake8-simplify
106106
'TID', # flake8-tidy-imports
107-
'TCH', # flake8-type-checking
107+
'TC', # flake8-type-checking
108108
'INT', # flake8-gettext
109109
'ARG', # flake8-unused-arguments
110110
'PTH', # flake8-use-pathlib
111111
'TD', # flake8-todos
112112
'FIX', # flake8-fixme
113113
'ERA', # eradicate
114+
'PD', # pandas-vet
114115
'PL', # pylint
115116
'TRY', # tryceratops
116117
'FLY', # flynt
117118
'NPY', # numpy specific rules
118119
'PERF', # perflint
119120
'FURB', # refurb
120-
'LOG', # flake8-logging
121+
'DOC', # pydoclint
121122
'RUF', # ruff-specific rules
122123
]
123124

124-
ignore = ['ANN101', # missing-type-self
125-
'D203', # one-blank-line-before-class
126-
'D212', # multi-line-summary-first-line
125+
ignore = ['D203', # one-blank-line-before-class
126+
'D212', # multi-line-summary-first-line
127127
'S603', # subprocess-without-shell-equals-true
128-
# Ignore rulues below are actually to prevent conflicts between formatting and linting (with fixing)
128+
'ANN204', # missing-return-type-special-method (__init__, __new__, etc.)
129+
'DOC201', # return-not-documented (too strict for existing codebase)
130+
'DOC501', # raised-exception-not-documented (too strict for existing codebase)
131+
# Ignore rules below to prevent conflicts between formatting and linting (with fixing)
129132
# cf. https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
130-
'COM812', # missing-trailing-comma
131-
'COM819', # prohibited-trailing-comma
132133
'D206', # indent-with-spaces
133-
'E111', # indentation-with-invalid-multiple
134-
'E114', # indentation-with-invalid-multiple-comment
135-
'E117', # over-indented
136134
'ISC001', # single-line-implicit-string-concatenation
137135
'ISC002', # multi-line-implicit-string-concatenation
138136
'Q000', # bad-quotes-inline-string
139137
'Q001', # bad-quotes-multiline-string
140138
'Q002', # bad-quotes-docstring
141139
'Q003', # avoidable-escaped-quote
142-
'S603', # subprocess-without-shell-equals-true
143-
'W191', # tab-indentation
144140
]
145141

146142
[tool.ruff.format]
@@ -151,14 +147,12 @@ skip-magic-trailing-comma = false
151147

152148
[tool.ruff.lint.per-file-ignores]
153149

154-
'tests/python/*.py' = ['S101', 'SLF001', 'PLR0913', 'PLR2004', 'D']
150+
'tests/python/*.py' = ['S101', 'SLF001', 'PLR0913', 'PLR2004', 'D', 'DOC', 'PYI024']
155151

156152
[tool.ruff.lint.flake8-annotations]
157153
allow-star-arg-any = true
158154
ignore-fully-untyped = true
159-
mypy-init-return = true
160155
suppress-dummy-args = true
161-
suppress-none-returning = true
162156

163157
[tool.ruff.lint.flake8-quotes]
164158
docstring-quotes = 'double'

0 commit comments

Comments
 (0)