From 005ba8c1935fbe5180f8941724880c767e441ff7 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 28 Dec 2024 19:52:22 -0500 Subject: [PATCH] Enable Ruff ANN2 (falke8-annotations, autofixes only) --- pyproject.toml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 424fb108d175..ce23b8f5a198 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,8 @@ select = [ "E", # pycodestyle Error "F", # Pyflakes "W", # pycodestyle Warning + # Only include flake8-annotations rules that are autofixable. Otherwise leave this to mypy+pyright + "ANN2", # PYI: only enable rules that have autofixes and that we always want to fix (even manually), # avoids duplicate # noqa with flake8-pyi and flake8-noqa flagging `PYI` codes # See https://github.com/plinss/flake8-noqa/issues/22 @@ -102,11 +104,9 @@ ignore = [ [tool.ruff.lint.per-file-ignores] "*.pyi" = [ - # Ruff 0.8.0 added sorting of __all__ and __slots_. - # There is no consensus on whether we want to apply this to stubs, so keeping the status quo. - # See https://github.com/python/typeshed/pull/13108 - "RUF022", - "RUF023", + # A lot of stubs are incomplete on purpose, and that's configured through pyright + # Some ANN204 (special method) are autofixable in stubs, but not all. + "ANN2", # Missing return type annotation for ... # Most flake8-bugbear rules don't apply for third-party stubs like typeshed. # B033 could be slightly useful but Ruff doesn't have per-file select "B", # flake8-bugbear @@ -115,6 +115,11 @@ ignore = [ # Stubs can sometimes re-export entire modules. # Issues with using a star-imported name will be caught by type-checkers. "F405", # may be undefined, or defined from star imports + # Ruff 0.8.0 added sorting of __all__ and __slots_. + # There is no consensus on whether we want to apply this to stubs, so keeping the status quo. + # See https://github.com/python/typeshed/pull/13108 + "RUF022", + "RUF023", ] # See comment on black's force-exclude config above "*_pb2.pyi" = [