diff --git a/pyproject.toml b/pyproject.toml index c3e1cdd1c112..30812adf1bb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ exclude = [ select = [ "FA", # flake8-future-annotations "I", # isort + "UP", # pyupgrade # Only enable rules that have safe autofixes: "F401", # Remove unused imports "PYI009", # use `...`, not `pass`, in empty class bodies @@ -39,14 +40,21 @@ select = [ "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 - "UP004", # Remove explicit `object` inheritance - "UP006", # PEP-585 autofixes - "UP007", # PEP-604 autofixes - "UP013", # Class-based syntax for TypedDicts - "UP014", # Class-based syntax for NamedTuples - "UP019", # Use str over typing.Text - "UP035", # import from typing, not typing_extensions, wherever possible - "UP039", # don't use parens after a class definition with no bases +] +ignore = [ + # Slower and more verbose https://github.com/astral-sh/ruff/issues/7871 + "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` +] + +[tool.ruff.lint.per-file-ignores] +# Disable "modernization" rules with autofixes from test cases as they often +# deliberately contain code that might not be considered idiomatic or modern +# These can be run manually once in a while +"**/test_cases/**/*.py" = ["UP"] +# Generated protobuf files: +# TODO: Re-run sync_tensorflow_protobuf_stubs.sh with this rule enabled to remove this entry +"*_pb2.pyi" = [ + "UP036", # Version block is outdated for minimum Python version ] [tool.ruff.lint.isort] diff --git a/stubs/six/six/moves/builtins.pyi b/stubs/six/six/moves/builtins.pyi index 9596ba032aa0..1f3812602c5e 100644 --- a/stubs/six/six/moves/builtins.pyi +++ b/stubs/six/six/moves/builtins.pyi @@ -1 +1,4 @@ -from builtins import * +# flake8: noqa: NQA102 # https://github.com/plinss/flake8-noqa/issues/22 +# six explicitly re-exports builtins. Normally this is something we'd want to avoid. +# But this is specifically a compatibility package. +from builtins import * # noqa: UP029