diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04bf9b2..6e88938 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,11 +51,11 @@ repos: - id: yamllint - repo: https://github.com/asottile/blacken-docs - rev: 1.20.0 + rev: 1.19.1 hooks: - id: blacken-docs - args: [-S, -l, '120'] - additional_dependencies: [black==22.12.0] + args: [--line-length=120] + additional_dependencies: [ruff>=0.14.0] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.14.10 diff --git a/CHANGELOG.md b/CHANGELOG.md index a0bba04..0445305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Repository - Fixed Windows CI by using pip to install cppcheck (Chocolatey package is broken) +- Modernize ruff configuration to follow latest guidelines + - Remove deprecated settings (`target-version`, `ANN101`, `ASYNC1`, etc.) + - Replace `TCH` with `TC` (renamed rule set) + - Add new rule sets: `DOC`, `PYI`, `PD` + - Configure `blacken-docs` to use ruff instead of black - Clarify where to put the settings in `pyproject.toml` - 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 - Update `github.com/codespell-project/codespell` hook to v2.4.1 - Update `github.com/shellcheck-py/shellcheck-py` hook to v0.11.0.1 - Update `github.com/adrienverge/yamllint.git` hook to v1.37.1 -- Update `github.com/asottile/blacken-docs` hook to 1.20.0 +- Update `github.com/asottile/blacken-docs` hook to 1.19.1 - Update `github.com/astral-sh/ruff-pre-commit` hook to v0.14.10 ## [v1.9.6] - 2024-06-02 diff --git a/cmake_pc_hooks/_argparse.py b/cmake_pc_hooks/_argparse.py index 7cf2312..205940d 100644 --- a/cmake_pc_hooks/_argparse.py +++ b/cmake_pc_hooks/_argparse.py @@ -126,7 +126,6 @@ def _load_data_from_toml( elements (ie. no nested sections). Args: - namespace: Namespace to store results into path: Path to TOML file section: Name of section to load in TOML file path_must_exist: Whether a missing TOML file is considered an error or not diff --git a/pyproject.toml b/pyproject.toml index 833335d..ffc948d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,6 @@ namespaces = false [tool.ruff] line-length = 120 -target-version = 'py310' [tool.ruff.lint] @@ -77,10 +76,9 @@ select = ['F', # pyflakes 'N', # pep8-naming 'D', # pydocstyle 'UP', # pyupgrade - 'YTT', # flake-2020 + 'YTT', # flake8-2020 'ANN', # flake8-annotations 'ASYNC', # flake8-async - 'ASYNC1', # flake8-trio 'S', # flake8-bandit 'BLE', # flake8-blind-except 'FBT', # flake8-boolean-trap @@ -94,8 +92,10 @@ select = ['F', # pyflakes 'FA', # flake8-future-annotations 'ISC', # flake8-implicit-str-concat 'ICN', # flake8-import-conventions + 'LOG', # flake8-logging 'G', # flake8-logging-format 'PIE', # flake8-pie + 'PYI', # flake8-pyi 'PT', # flake8-pytest-style 'Q', # flake8-quotes 'RSE', # flake8-raise @@ -104,43 +104,39 @@ select = ['F', # pyflakes 'SLOT', # flake8-slots 'SIM', # flake8-simplify 'TID', # flake8-tidy-imports - 'TCH', # flake8-type-checking + 'TC', # flake8-type-checking 'INT', # flake8-gettext 'ARG', # flake8-unused-arguments 'PTH', # flake8-use-pathlib 'TD', # flake8-todos 'FIX', # flake8-fixme 'ERA', # eradicate + 'PD', # pandas-vet 'PL', # pylint 'TRY', # tryceratops 'FLY', # flynt 'NPY', # numpy specific rules 'PERF', # perflint 'FURB', # refurb - 'LOG', # flake8-logging + 'DOC', # pydoclint 'RUF', # ruff-specific rules ] -ignore = ['ANN101', # missing-type-self - 'D203', # one-blank-line-before-class - 'D212', # multi-line-summary-first-line +ignore = ['D203', # one-blank-line-before-class + 'D212', # multi-line-summary-first-line 'S603', # subprocess-without-shell-equals-true - # Ignore rulues below are actually to prevent conflicts between formatting and linting (with fixing) + 'ANN204', # missing-return-type-special-method (__init__, __new__, etc.) + 'DOC201', # return-not-documented (too strict for existing codebase) + 'DOC501', # raised-exception-not-documented (too strict for existing codebase) + # Ignore rules below to prevent conflicts between formatting and linting (with fixing) # cf. https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - 'COM812', # missing-trailing-comma - 'COM819', # prohibited-trailing-comma 'D206', # indent-with-spaces - 'E111', # indentation-with-invalid-multiple - 'E114', # indentation-with-invalid-multiple-comment - 'E117', # over-indented 'ISC001', # single-line-implicit-string-concatenation 'ISC002', # multi-line-implicit-string-concatenation 'Q000', # bad-quotes-inline-string 'Q001', # bad-quotes-multiline-string 'Q002', # bad-quotes-docstring 'Q003', # avoidable-escaped-quote - 'S603', # subprocess-without-shell-equals-true - 'W191', # tab-indentation ] [tool.ruff.format] @@ -151,14 +147,12 @@ skip-magic-trailing-comma = false [tool.ruff.lint.per-file-ignores] -'tests/python/*.py' = ['S101', 'SLF001', 'PLR0913', 'PLR2004', 'D'] +'tests/python/*.py' = ['S101', 'SLF001', 'PLR0913', 'PLR2004', 'D', 'DOC', 'PYI024'] [tool.ruff.lint.flake8-annotations] allow-star-arg-any = true ignore-fully-untyped = true -mypy-init-return = true suppress-dummy-args = true -suppress-none-returning = true [tool.ruff.lint.flake8-quotes] docstring-quotes = 'double'