From d228e0f2c1491a0f6b7908d2552b95f8ec4cace3 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Tue, 12 Aug 2025 14:06:25 -0400 Subject: [PATCH 01/10] style: update precommit and pyproject --- .pre-commit-config.yaml | 19 +++++-- pyproject.toml | 113 +++++++++++++++++++++++++++++++--------- 2 files changed, 105 insertions(+), 27 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 581fa24..4de48aa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,9 +6,22 @@ repos: entry: pyright language: system types: [python] +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: detect-private-key + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-merge-conflict + - id: detect-aws-credentials + args: [ --allow-missing-credentials ] + - id: mixed-line-ending + args: [ --fix=lf ] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.4 + rev: v0.12.8 hooks: - - id: ruff - id: ruff-format - args: [ --check ] + - id: ruff + args: [ --fix, --exit-non-zero-on-fix ] +minimum_pre_commit_version: 4.2.0 diff --git a/pyproject.toml b/pyproject.toml index 79a7352..02c1f15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,8 @@ dev = [ "mypy-extensions ~= 1.0", "pre-commit ~= 3.4", "pyright~=1.1", - "ruff == 0.4.4", + "ruff == 0.12.8", + "pre-commit>=4.2.0", ] tests = [ "pytest-cov ~= 4.1", @@ -113,60 +114,124 @@ line-length = 100 [tool.ruff.lint] select = [ - "F", # https://docs.astral.sh/ruff/rules/#pyflakes-f - "E", - "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w - "I", # https://docs.astral.sh/ruff/rules/#isort-i - "N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n - "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up - "YTT", # https://docs.astral.sh/ruff/rules/#flake8-2020-ytt - "S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s - "B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b - "A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a - "C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 + "ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann + "ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async + "S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s + "B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b + "A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a + "COM", # https://docs.astral.sh/ruff/rules/#flake8-commas-com + "C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 "DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz - "EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em + "T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz + "EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em + "ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc + "ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn "LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log - "G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g + "G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g + "INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp "PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie - "PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt + "T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20 + "PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt + "Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q "RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse "RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret + "SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf "SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim + "SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot + "TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid "ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg "PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth - "PL", # https://docs.astral.sh/ruff/rules/#pylint-pl - "TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try - "PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf + "I", # https://docs.astral.sh/ruff/rules/#isort-i + "N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n + "PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf + "E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w + "D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d + "F", # https://docs.astral.sh/ruff/rules/#pyflakes-f + "PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh + "PLC", # https://docs.astral.sh/ruff/rules/#convention-c + "PLE", # https://docs.astral.sh/ruff/rules/#error-e_1 + "PLW", # https://docs.astral.sh/ruff/rules/#warning-plw + "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up + "FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf + "TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try ] fixable = [ - "F401", - "F541", - "I", - "D", - "UP", + "ANN", + "ASYNC", "B", "C4", "EM", + "ISC", + "ICN", + "LOG", + "G", "PIE", "PT", "RSE", "RET", "SIM", + "TID", + "PTH", + "I", + "N", "PERF", + "D", + "F401", + "F541", + "PGH", + "PLC", + "PLE", + "PLW", + "UP", + "FURB", "RUF", + "TRY" ] ignore = [ # ignore for compatibility with formatter + "D206", + "D300", "W191", "E111", "E114", "E117", + "E501", + "W191", "S321", # other + "ANN002", + "ANN003", "PLR0913", + "PLC0206", + "EM101", + "D213", + "D400", + "d415", ] [tool.ruff.lint.per-file-ignores] -"tests/*" = ["S101"] +# ANN001 - missing-type-function-argument +# ANN2 - missing-return-type +# D100 - undocumented-public-module +# D102 - undocumented-public-class +# D103 - undocumented-public-function +# S101 - assert +# B011 - assert-false +# INP001 - implicit-namespace-package +"tests/*" = [ + "ANN001", + "ANN2", + "D100", + "D102", + "D103", + "S101", + "B011", + "INP001" +] + +[tool.ruff.lint.flake8-annotations] +mypy-init-return = true + +[tool.ruff.format] +docstring-code-format = true From cc16ba9ef6bd7d08b62fd312619315db46f3c142 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Tue, 12 Aug 2025 16:28:00 -0400 Subject: [PATCH 02/10] add precommit --- .github/workflows/python-package.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e511102..e41107b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -44,6 +44,26 @@ jobs: run: | ruff format --check . + precommit_hooks: + runs-on: ubuntu-latest + strategy: + matrix: + cmd: + - "end-of-file-fixer" + - "trailing-whitespace" + - "mixed-line-ending" + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - uses: pre-commit/action@v3.0.1 + with: + extra_args: ${{ matrix.cmd }} --all-files + test: runs-on: ubuntu-latest From 227bcd13c82c32ba8c5af6de85c108d7572a7b80 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Tue, 12 Aug 2025 16:36:00 -0400 Subject: [PATCH 03/10] style: update style tooling, run it --- .github/workflows/labels.yml | 2 +- pyproject.toml | 7 ++++--- src/biocommons/example/__main__.py | 8 ++++---- src/biocommons/example/marvin.py | 4 ++-- src/biocommons/example/marvin_adjacent_test.py | 6 +++--- src/biocommons/example/quotes.yaml | 6 +++--- src/biocommons/example/tests/__init__.py | 1 + src/biocommons/example/tests/conftest.py | 7 +++++-- src/biocommons/example/tests/marvin_subdir_test.py | 6 +++--- 9 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 52c578c..188466c 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -26,4 +26,4 @@ jobs: https://raw.githubusercontent.com/biocommons/.github/main/etc/labels.yml .github/labels.yml - delete-other-labels: false \ No newline at end of file + delete-other-labels: false diff --git a/pyproject.toml b/pyproject.toml index 02c1f15..0a66239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,10 +23,9 @@ dev = [ "build ~= 0.8", "ipython ~= 8.4", "mypy-extensions ~= 1.0", - "pre-commit ~= 3.4", + "pre-commit >= 4.2.0", "pyright~=1.1", "ruff == 0.12.8", - "pre-commit>=4.2.0", ] tests = [ "pytest-cov ~= 4.1", @@ -199,6 +198,7 @@ ignore = [ "E501", "W191", "S321", + "COM812", # other "ANN002", "ANN003", @@ -206,8 +206,9 @@ ignore = [ "PLC0206", "EM101", "D213", + "D203", "D400", - "d415", + "D415", ] [tool.ruff.lint.per-file-ignores] diff --git a/src/biocommons/example/__main__.py b/src/biocommons/example/__main__.py index 24dcdf9..8eaa51a 100644 --- a/src/biocommons/example/__main__.py +++ b/src/biocommons/example/__main__.py @@ -8,9 +8,9 @@ _logger = logging.getLogger(__name__) -def main(): # pragma: no cover +def main() -> None: # pragma: no cover """marvin.example main""" - import coloredlogs + import coloredlogs # noqa: PLC0415 logging.Formatter.converter = time.gmtime coloredlogs.install( @@ -22,8 +22,8 @@ def main(): # pragma: no cover quote = marvin.get_quote() _logger.warning("Got quote from Marvin (len=%s)", len(quote)) - print("Marvin says:") - print(quote) + print("Marvin says:") # noqa: T201 + print(quote) # noqa: T201 if __name__ == "__main__": diff --git a/src/biocommons/example/marvin.py b/src/biocommons/example/marvin.py index f5dfb79..73c9095 100644 --- a/src/biocommons/example/marvin.py +++ b/src/biocommons/example/marvin.py @@ -18,7 +18,7 @@ def is_alive() -> bool: - """tests whether Marvin is alive + """Test whether Marvin is alive >>> is_alive() is True True @@ -28,7 +28,7 @@ def is_alive() -> bool: def get_quote() -> str: - """return random Marvin quote + """Return random Marvin quote eg> get_quote() "There's only one life-form as intelligent..." diff --git a/src/biocommons/example/marvin_adjacent_test.py b/src/biocommons/example/marvin_adjacent_test.py index 5498dd1..da59758 100644 --- a/src/biocommons/example/marvin_adjacent_test.py +++ b/src/biocommons/example/marvin_adjacent_test.py @@ -1,8 +1,8 @@ """biocommons.example test, adjacent to code""" -from .marvin import get_quote +from biocommons.example.marvin import get_quote -def test_get_quote(): - """test get_quote""" +def test_get_quote() -> None: + """Test get_quote""" assert get_quote() is not None # noqa: S101 diff --git a/src/biocommons/example/quotes.yaml b/src/biocommons/example/quotes.yaml index 16b23f6..e85be62 100644 --- a/src/biocommons/example/quotes.yaml +++ b/src/biocommons/example/quotes.yaml @@ -12,15 +12,15 @@ quotes: fifty thousand times more intelligent than you and even I don't know the answer. It gives me a headache just trying to think down to your level. - + - >- There's only one life-form as intelligent as me within thirty parsecs of here and that's me. - + - >- I wish you'd just tell me rather trying to engage my enthusiasm because I haven't got one. - + - >- And then, of course, I've got this terrible pain in all the diodes down my left side. diff --git a/src/biocommons/example/tests/__init__.py b/src/biocommons/example/tests/__init__.py index e69de29..7c91a3a 100644 --- a/src/biocommons/example/tests/__init__.py +++ b/src/biocommons/example/tests/__init__.py @@ -0,0 +1 @@ +"""Declare tests internal to src directory""" diff --git a/src/biocommons/example/tests/conftest.py b/src/biocommons/example/tests/conftest.py index 79d7cd9..957005b 100644 --- a/src/biocommons/example/tests/conftest.py +++ b/src/biocommons/example/tests/conftest.py @@ -1,10 +1,13 @@ +"""Provide fixtures to tests.""" + import importlib.resources import pytest import yaml -@pytest.fixture() -def all_quotes(): +@pytest.fixture +def all_quotes() -> None: + """Provide quotes fixture""" quotes_stream = importlib.resources.files("example").joinpath("quotes.yaml").read_text() return yaml.load(quotes_stream, Loader=yaml.SafeLoader)["quotes"] diff --git a/src/biocommons/example/tests/marvin_subdir_test.py b/src/biocommons/example/tests/marvin_subdir_test.py index ff94067..11c4b82 100644 --- a/src/biocommons/example/tests/marvin_subdir_test.py +++ b/src/biocommons/example/tests/marvin_subdir_test.py @@ -1,9 +1,9 @@ """biocommons.example test, within tests directory adjacent to source""" -from ..marvin import get_quote +from biocommons.example.marvin import get_quote -def test_get_quote(all_quotes): - """test get_quote""" +def test_get_quote(all_quotes: list[str]) -> None: + """Test get_quote""" # NB: all_quotes argument is a test fixture; see ./conftest.py assert get_quote() in all_quotes # noqa: S101 From e120b98d4455af0bc21e7d3777a4eaecbd2a1e39 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Tue, 12 Aug 2025 16:49:37 -0400 Subject: [PATCH 04/10] merge into cqa job --- .github/workflows/python-package.yml | 29 ++++++++++++---------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e41107b..40886c8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -44,25 +44,20 @@ jobs: run: | ruff format --check . - precommit_hooks: - runs-on: ubuntu-latest - strategy: - matrix: - cmd: - - "end-of-file-fixer" - - "trailing-whitespace" - - "mixed-line-ending" - steps: - - uses: actions/checkout@v4 + - name: Ensure EOF line + uses: pre-commit/action@v3.0.1 + with: + extra_args: end-of-file-fixer --all-files - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: 3.12 + - name: Fix trailing whitespace + uses: pre-commit/action@v3.0.1 + with: + extra_args: trailing-whitespace --all-files - - uses: pre-commit/action@v3.0.1 - with: - extra_args: ${{ matrix.cmd }} --all-files + - name: Fix mixed line endings + uses: pre-commit/action@v3.0.1 + with: + extra_args: mixed-line-ending --all-files test: runs-on: ubuntu-latest From de7ed46c0f0363d68eb7d1b5702d8efb8439cde0 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Tue, 12 Aug 2025 21:09:22 -0400 Subject: [PATCH 05/10] add some more configs --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0a66239..d57c734 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,7 +122,6 @@ select = [ "C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 "DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz "T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz - "EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em "ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc "ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn "LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log @@ -160,7 +159,6 @@ fixable = [ "ASYNC", "B", "C4", - "EM", "ISC", "ICN", "LOG", @@ -204,11 +202,12 @@ ignore = [ "ANN003", "PLR0913", "PLC0206", - "EM101", "D213", "D203", "D400", "D415", + "TRY003", + "B019", ] [tool.ruff.lint.per-file-ignores] From 544fc6de4c2712329378b2ef62c015bb601d85d3 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 20 Aug 2025 12:25:01 -0400 Subject: [PATCH 06/10] redo with some laxer rules --- pyproject.toml | 54 ++++++++---------------- src/biocommons/example/marvin.py | 2 +- src/biocommons/example/tests/__init__.py | 2 +- src/biocommons/example/tests/conftest.py | 6 +-- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aa03265..f0cf051 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,6 +105,11 @@ exclude_lines = [ [tool.ruff] src = ["src", "tests"] line-length = 100 +exclude = [ + "bin", + "sbin", + "docs", +] [tool.ruff.lint] select = [ @@ -143,43 +148,13 @@ select = [ "PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh "PLC", # https://docs.astral.sh/ruff/rules/#convention-c "PLE", # https://docs.astral.sh/ruff/rules/#error-e_1 + "PLR", # https://docs.astral.sh/ruff/rules/#refactor-plr "PLW", # https://docs.astral.sh/ruff/rules/#warning-plw "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up "FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf "TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try ] -fixable = [ - "ANN", - "ASYNC", - "B", - "C4", - "ISC", - "ICN", - "LOG", - "G", - "PIE", - "PT", - "RSE", - "RET", - "SIM", - "TID", - "PTH", - "I", - "N", - "PERF", - "D", - "F401", - "F541", - "PGH", - "PLC", - "PLE", - "PLW", - "UP", - "FURB", - "RUF", - "TRY" -] ignore = [ # ignore for compatibility with formatter "D206", @@ -192,17 +167,24 @@ ignore = [ "W191", "S321", "COM812", - # other + # don't require types on *args, **kwargs "ANN002", "ANN003", - "PLR0913", - "PLC0206", - "D213", + # subjective pylint thresholds + "PLR0904", + "PLR091", + "PLR1702", + # excessive docstring requirements + "D105", + "D205", "D203", + "D213", # conflicts with D212 "D400", + "D401", "D415", + # excessive exception message requirements "TRY003", - "B019", + # excessive type ignore requirements "PGH003", ] diff --git a/src/biocommons/example/marvin.py b/src/biocommons/example/marvin.py index 73c9095..b88b5c0 100644 --- a/src/biocommons/example/marvin.py +++ b/src/biocommons/example/marvin.py @@ -18,7 +18,7 @@ def is_alive() -> bool: - """Test whether Marvin is alive + """Tests whether Marvin is alive >>> is_alive() is True True diff --git a/src/biocommons/example/tests/__init__.py b/src/biocommons/example/tests/__init__.py index 7c91a3a..6e03199 100644 --- a/src/biocommons/example/tests/__init__.py +++ b/src/biocommons/example/tests/__init__.py @@ -1 +1 @@ -"""Declare tests internal to src directory""" +# noqa: D104 diff --git a/src/biocommons/example/tests/conftest.py b/src/biocommons/example/tests/conftest.py index 957005b..4e7dd24 100644 --- a/src/biocommons/example/tests/conftest.py +++ b/src/biocommons/example/tests/conftest.py @@ -1,5 +1,4 @@ -"""Provide fixtures to tests.""" - +# noqa: D100 import importlib.resources import pytest @@ -7,7 +6,6 @@ @pytest.fixture -def all_quotes() -> None: - """Provide quotes fixture""" +def all_quotes() -> dict: # noqa: D103 quotes_stream = importlib.resources.files("example").joinpath("quotes.yaml").read_text() return yaml.load(quotes_stream, Loader=yaml.SafeLoader)["quotes"] From 0fba9472106935a6b9cece3eb39c2d359a356438 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 20 Aug 2025 12:26:56 -0400 Subject: [PATCH 07/10] chill --- pyproject.toml | 1 + src/biocommons/example/marvin_adjacent_test.py | 2 +- src/biocommons/example/tests/marvin_subdir_test.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f0cf051..0a5fb57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,6 +181,7 @@ ignore = [ "D213", # conflicts with D212 "D400", "D401", + "D403", "D415", # excessive exception message requirements "TRY003", diff --git a/src/biocommons/example/marvin_adjacent_test.py b/src/biocommons/example/marvin_adjacent_test.py index da59758..ee450fa 100644 --- a/src/biocommons/example/marvin_adjacent_test.py +++ b/src/biocommons/example/marvin_adjacent_test.py @@ -4,5 +4,5 @@ def test_get_quote() -> None: - """Test get_quote""" + """test get_quote""" assert get_quote() is not None # noqa: S101 diff --git a/src/biocommons/example/tests/marvin_subdir_test.py b/src/biocommons/example/tests/marvin_subdir_test.py index 11c4b82..a7eef8f 100644 --- a/src/biocommons/example/tests/marvin_subdir_test.py +++ b/src/biocommons/example/tests/marvin_subdir_test.py @@ -4,6 +4,6 @@ def test_get_quote(all_quotes: list[str]) -> None: - """Test get_quote""" + """test get_quote""" # NB: all_quotes argument is a test fixture; see ./conftest.py assert get_quote() in all_quotes # noqa: S101 From 5792c6bfa6fe236090d3f9b59fb2261d2e82db89 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Sat, 23 Aug 2025 16:31:23 -0400 Subject: [PATCH 08/10] small tweaks --- Makefile | 3 +- pyproject.toml | 75 +++++++++++++++++++------------------------------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index bbcce4d..32b5a5a 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ build: %: ############################################################################ #= TESTING -# see test configuration in setup.cfg +# see test configuration in pyproject.toml #=> test: execute tests #=> test-code: test code (including embedded doctests) @@ -126,6 +126,7 @@ cleaner: clean rm -frv **/*.pyc rm -frv **/*.orig rm -frv **/*.rej + rm -fvr .ruff_cache #=> cleanest: remove files and directories that require more time/network fetches to rebuild .PHONY: cleanest diff --git a/pyproject.toml b/pyproject.toml index 0a5fb57..eee4165 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,50 +112,27 @@ exclude = [ ] [tool.ruff.lint] -select = [ - "ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann - "ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async - "S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s - "B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b - "A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a - "COM", # https://docs.astral.sh/ruff/rules/#flake8-commas-com - "C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 - "DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz - "T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz - "ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc - "ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn - "LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log - "G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g - "INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp - "PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie - "T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20 - "PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt - "Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q - "RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse - "RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret - "SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf - "SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim - "SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot - "TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid - "ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg - "PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth - "I", # https://docs.astral.sh/ruff/rules/#isort-i - "N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n - "PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf - "E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w - "D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d - "F", # https://docs.astral.sh/ruff/rules/#pyflakes-f - "PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh - "PLC", # https://docs.astral.sh/ruff/rules/#convention-c - "PLE", # https://docs.astral.sh/ruff/rules/#error-e_1 - "PLR", # https://docs.astral.sh/ruff/rules/#refactor-plr - "PLW", # https://docs.astral.sh/ruff/rules/#warning-plw - "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up - "FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb - "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf - "TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try -] ignore = [ + # not used + "AIR", + "ERA", + "FAST", + "YTT", + "FBT", + "CPY", + "DJ", + "EM", + "EXE", + "FIX", + "FA", + "INT", + "PYI", + "TID", + "TD", + "TC", + "C90", + "NPY", + "PD", # ignore for compatibility with formatter "D206", "D300", @@ -187,26 +164,30 @@ ignore = [ "TRY003", # excessive type ignore requirements "PGH003", + # misc unnecessary readability requirements + "RET504", ] [tool.ruff.lint.per-file-ignores] # ANN001 - missing-type-function-argument # ANN2 - missing-return-type # D100 - undocumented-public-module -# D102 - undocumented-public-class +# D101 - undocumented-public-class +# D102 - undocumented-public-method # D103 - undocumented-public-function # S101 - assert # B011 - assert-false # INP001 - implicit-namespace-package +# SLF001 - private-member-access "tests/*" = [ "ANN001", "ANN2", "D100", - "D102", - "D103", + "D10", "S101", "B011", - "INP001" + "INP001", + "SLF001", ] [tool.ruff.lint.flake8-annotations] From f87ed99abc89bed09e529815fa479fdf9aab7926 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Sat, 23 Aug 2025 16:45:47 -0400 Subject: [PATCH 09/10] doh --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index eee4165..2a39d5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,6 +112,7 @@ exclude = [ ] [tool.ruff.lint] +select = ["ALL"] ignore = [ # not used "AIR", From cfd0b121ffc4a3f74a6fd54ac32052e197ee45a3 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Tue, 26 Aug 2025 11:37:50 -0400 Subject: [PATCH 10/10] add ignore ble --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ae38fd6..2357745 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -179,6 +179,7 @@ ignore = [ # B011 - assert-false # INP001 - implicit-namespace-package # SLF001 - private-member-access +# BLE001 - blind-except "tests/*" = [ "ANN001", "ANN2", @@ -188,6 +189,7 @@ ignore = [ "B011", "INP001", "SLF001", + "BLE001", ] [tool.ruff.lint.flake8-annotations]