Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable nearly all pyupgrade rules (except on test cases) #11499

Merged
merged 11 commits into from
Feb 29, 2024
19 changes: 11 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,14 +40,16 @@ 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 = [
# We like explicit open modes
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
"UP015", # Unnecessary open mode parameters
]

[tool.ruff.lint.extend-per-file-ignores]
# Generated protobuf files:
"*_pb2.pyi" = [
"UP036", # Version block is outdated for minimum Python version
]

[tool.ruff.lint.isort]
Expand Down
2 changes: 1 addition & 1 deletion scripts/stubsabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ async def determine_action(stub_path: Path, session: aiohttp.ClientSession) -> U
)


@functools.lru_cache()
@functools.lru_cache
def get_origin_owner() -> str:
output = subprocess.check_output(["git", "remote", "get-url", "origin"], text=True).strip()
match = re.match(r"([email protected]:|https://github.com/)(?P<owner>[^/]+)/(?P<repo>[^/\s]+)", output)
Expand Down
5 changes: 4 additions & 1 deletion stubs/six/six/moves/builtins.pyi
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/pytype_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def run_all_tests(*, files_to_test: Sequence[str], print_stderr: bool, dry_run:
missing_modules = get_missing_modules(files_to_test)
print("Testing files with pytype...")
for i, f in enumerate(files_to_test):
python_version = "{0.major}.{0.minor}".format(sys.version_info)
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
if dry_run:
stderr = None
else:
Expand Down
Loading