From 89e0b691db72b237f961d402085a1bfafc4312e5 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 4 Sep 2024 19:50:07 -0400 Subject: [PATCH] Enable more Ruff PYI rules with autofixes (#12557) --- pyproject.toml | 30 +++++++++++++++++++----------- stdlib/builtins.pyi | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 272679e3e..6483bb197 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,18 +46,26 @@ select = [ "E", # pycodestyle Error "F", # Pyflakes "W", # pycodestyle Warning - # PYI: only enable rules that always autofix, avoids duplicate # noqa with flake8-pyi + # 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 - "PYI009", # use `...`, not `pass`, in empty class bodies - "PYI010", # function bodies must be empty - "PYI012", # class bodies must not contain `pass` - "PYI013", # non-empty class bodies must not contain `...` - "PYI016", # duplicate union member - "PYI020", # quoted annotations are always unnecessary in stubs - "PYI025", # always alias `collections.abc.Set` as `AbstractSet` when importing it - "PYI032", # use `object`, not `Any`, as the second parameter to `__eq__` - "PYI055", # multiple `type[T]` usages in a union - "PYI058", # use `Iterator` as the return type for `__iter__` methods + "PYI009", # Empty body should contain `...`, not pass + "PYI010", # Function body must contain only `...` + "PYI012", # Class bodies must not contain `pass` + "PYI013", # Non-empty class bodies must not contain `...` + "PYI014", # Only simple default values allowed for arguments + "PYI015", # Only simple default values allowed for assignments + "PYI016", # Duplicate union member `{}` + "PYI020", # Quoted annotations should not be included in stubs + "PYI025", # Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + # "PYI026", Waiting for this mypy bug to be fixed: https://github.com/python/mypy/issues/16581 + "PYI030", # Multiple literal members in a union. Use a single literal, e.g. `Literal[{}]` + "PYI032", # Prefer `object` to `Any` for the second parameter to `{method_name}` + "PYI036", # Star-args in `{method_name}` should be annotated with `object` + "PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics + "PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`. + "PYI058", # Use `{return_type}` as the return value for simple `{method}` methods + "PYI062", # Duplicate literal member `{}` ] extend-safe-fixes = [ "UP036", # Remove unnecessary `sys.version_info` blocks diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index cd735aa35..f70e3d6db 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1,3 +1,4 @@ +# ruff: noqa: PYI036 # This is the module declaring BaseException import _ast import _typeshed import sys