Skip to content

Select Ruff rules for modern type annotations #160

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

Merged
merged 4 commits into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,32 @@ extend = "pyproject.toml"

[lint]
extend-select = [
# upstream

"C901",
"PERF401",
"W",

# Ensure modern type annotation syntax and best practices
# Not including those covered by type-checkers or exclusive to Python 3.11+
"FA", # flake8-future-annotations
"F404", # late-future-import
"PYI", # flake8-pyi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule turns out to be noisy (PYI024 in particular). It requires re-writing all namedtuples to typing.NamedTuples and can't be fixed mechanically.

"UP006", # non-pep585-annotation
"UP007", # non-pep604-annotation
"UP010", # unnecessary-future-import
"UP035", # deprecated-import
"UP037", # quoted-annotation
"UP043", # unnecessary-default-type-args

# local
]
ignore = [
# upstream

# Typeshed rejects complex or non-literal defaults for maintenance and testing reasons,
# irrelevant to this project.
"PYI011", # typed-argument-default-in-stub
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
"E111",
Expand All @@ -23,6 +44,8 @@ ignore = [
"COM819",
"ISC001",
"ISC002",

# local
]

[format]
Expand Down
Loading