Import names from typing directly rather than importing module (#13761)

This commit is contained in:
Avasam
2025-04-12 19:10:09 +02:00
committed by GitHub
parent 7ffb7e0832
commit a045be8ed6
10 changed files with 43 additions and 34 deletions
+9
View File
@@ -83,6 +83,8 @@ select = [
"FURB169", # Compare the identities of `{object}` and None instead of their respective types
"FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups
"FURB187", # Use of assignment of `reversed` on list `{name}`
# Used for lint.flake8-import-conventions.aliases
"ICN001", # `{name}` should be imported as `{asname}`
# Autofixable flake8-use-pathlib only
"PTH201", # Do not pass the current directory explicitly to `Path`
"PTH210", # Invalid suffix passed to `.with_suffix()`
@@ -217,6 +219,8 @@ ignore = [
"PLC0414", # Import alias does not rename original package
]
"*_pb2.pyi" = [
# Special autogenerated typing --> typing_extensions aliases
"ICN001", # `{name}` should be imported as `{asname}`
# Leave the docstrings as-is, matching source
"D", # pydocstyle
# See comment on black's force-exclude config above
@@ -226,6 +230,11 @@ ignore = [
[tool.ruff.lint.pydocstyle]
convention = "pep257" # https://docs.astral.sh/ruff/settings/#lint_pydocstyle_convention
[tool.ruff.lint.flake8-import-conventions.aliases]
# Prevent aliasing these, as it causes false-negatives for certain rules
typing_extensions = "typing_extensions"
typing = "typing"
[tool.ruff.lint.isort]
split-on-trailing-comma = false
combine-as-imports = true