Address issues reported by ruff check (#11043)

* Resolve E713 and E714 (not in/is tests).

* Address UP018 (unnecessary str call).

* UP045 requires Python 3.10+.

* Address UP007 (X | Y for type annotations).

* Address UP035 (import Callable from collections.abc).

* Address UP006 (t.Dict -> dict).

* Address UP009 (UTF-8 encoding comment).

* Address UP034 (extraneous parantheses).

* Address SIM910 (dict.get() with None default).

* Address F401 (unused import).

* Address UP020 (use builtin open).

* Address B009 and B010 (getattr/setattr with constant name).

* Address SIM300 (Yoda conditions).

* UP029 isn't in use anyway.

* Address FLY002 (static join).

* Address B034 (re.sub positional args).

* Address B020 (loop variable overrides input).

* Address B017 (assert raise Exception).

* Address SIM211 (if expression with false/true).

* Address SIM113 (enumerate for loop).

* Address UP036 (sys.version_info checks).

* Remove unnecessary UP039.

* Address SIM201 (not ==).

* Address SIM212 (if expr with twisted arms).

* Add changelog fragment.

* Reformat.
This commit is contained in:
Felix Fontein
2025-11-08 05:05:21 +01:00
committed by GitHub
parent f5943201b9
commit 3478863ef0
77 changed files with 196 additions and 222 deletions

View File

@@ -19,59 +19,34 @@ ignore = [
"SIM108", # if-else-block-instead-of-if-exp
# To fix later:
"B905", # zip-without-explicit-strict - needs Python 3.10+
"UP045", # Use `X | None` for type annotations - needs Python 3.10+
# To fix:
"F401", # Unused import
"E721", # Type comparison
"E713", # "not in" test
"E714", # "not is" test
"F841", # Unused variable
"UP006", # Use `dict` instead of `t.Dict` for type annotation
"UP007", # Use `X | Y` for type annotations
"UP009", # UTF-8 encoding declaration is unnecessary
"UP014", # Convert `xxx` from `NamedTuple` functional to class syntax
"UP018", # Unnecessary `str` call (rewrite as a literal)
"UP020", # Use builtin `open`
"UP024", # Replace aliased errors with `OSError`
"UP028", # Replace `yield` over `for` loop with `yield from`
"UP029", # Unnecessary builtin import: `open`
"UP030", # Use implicit references for positional format fields
"UP031", # Use format specifiers instead of percent format
"UP034", # Avoid extraneous parentheses
"UP035", # Import from `collections.abc` instead: `Callable`
"UP036", # Version block is outdated for minimum Python version
"UP039", # Unnecessary parentheses after class definition
"UP041", # Replace aliased errors with `TimeoutError`
"UP045", # Use `X | None` for type annotations
"B007", # unused-loop-control-variable
"B009", # get-attr-with-constant
"B010", # set-attr-with-constant
"B015", # useless-comparison
"B017", # assert-raises-exception
"B020", # loop-variable-overrides-iterator
"B026", # star-arg-unpacking-after-keyword-arg
"B034", # re-sub-positional-args
"B904", # raise-without-from-inside-except
"SIM102", # collapsible-if
"SIM103", # needless-bool
"SIM110", # reimplemented-builtin
"SIM112", # uncapitalized-environment-variables
"SIM113", # enumerate-for-loop
"SIM114", # if-with-same-arms
"SIM115", # open-file-with-context-handler
"SIM116", # if-else-block-instead-of-dict-lookup
"SIM117", # multiple-with-statements
"SIM118", # in-dict-keys
"SIM201", # negate-equal-op
"SIM210", # if-expr-with-true-false
"SIM211", # if-expr-with-false-true
"SIM212", # if-expr-with-twisted-arms
"SIM300", # yoda-conditions
"SIM401", # if-else-block-instead-of-dict-get
"SIM910", # dict-get-with-none-default
"A001", # builtin-variable-shadowing
"A002", # builtin-argument-shadowing
"A004", # builtin-import-shadowing
"FLY002", # static-join-to-f-string
]
# Allow fix for all enabled rules (when `--fix`) is provided.