mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
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.
(cherry picked from commit 3478863ef0)
Co-authored-by: Felix Fontein <felix@fontein.de>
78 lines
2.8 KiB
TOML
78 lines
2.8 KiB
TOML
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
# SPDX-FileCopyrightText: 2025 Felix Fontein <felix@fontein.de>
|
|
|
|
line-length = 120
|
|
|
|
[lint]
|
|
# https://docs.astral.sh/ruff/rules/
|
|
|
|
select = ["A", "B", "E", "F", "FA", "FLY", "UP", "SIM"]
|
|
ignore = [
|
|
# Better keep ignored (for now)
|
|
"F811", # Redefinition of unused `xxx` (happens a lot for fixtures in unit tests)
|
|
"E402", # Module level import not at top of file
|
|
"E741", # Ambiguous variable name
|
|
"UP012", # unnecessary-encode-utf8
|
|
"UP015", # Unnecessary mode argument
|
|
"SIM105", # suppressible-exception
|
|
"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:
|
|
"E721", # Type comparison
|
|
"F841", # Unused variable
|
|
"UP014", # Convert `xxx` from `NamedTuple` functional to class syntax
|
|
"UP024", # Replace aliased errors with `OSError`
|
|
"UP028", # Replace `yield` over `for` loop with `yield from`
|
|
"UP030", # Use implicit references for positional format fields
|
|
"UP031", # Use format specifiers instead of percent format
|
|
"UP041", # Replace aliased errors with `TimeoutError`
|
|
"B007", # unused-loop-control-variable
|
|
"B015", # useless-comparison
|
|
"B026", # star-arg-unpacking-after-keyword-arg
|
|
"B904", # raise-without-from-inside-except
|
|
"SIM102", # collapsible-if
|
|
"SIM103", # needless-bool
|
|
"SIM110", # reimplemented-builtin
|
|
"SIM112", # uncapitalized-environment-variables
|
|
"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
|
|
"SIM210", # if-expr-with-true-false
|
|
"SIM401", # if-else-block-instead-of-dict-get
|
|
"A001", # builtin-variable-shadowing
|
|
"A002", # builtin-argument-shadowing
|
|
"A004", # builtin-import-shadowing
|
|
]
|
|
|
|
# Allow fix for all enabled rules (when `--fix`) is provided.
|
|
fixable = ["ALL"]
|
|
unfixable = []
|
|
|
|
# Allow unused variables when underscore-prefixed or starting with dummy
|
|
dummy-variable-rgx = "^(_|dummy).*$"
|
|
|
|
[lint.pycodestyle]
|
|
max-line-length = 160
|
|
|
|
[format]
|
|
# https://docs.astral.sh/ruff/formatter/#configuration
|
|
|
|
# Like Black, use double quotes for strings.
|
|
quote-style = "double"
|
|
|
|
# Like Black, indent with spaces, rather than tabs.
|
|
indent-style = "space"
|
|
|
|
# Like Black, respect magic trailing commas.
|
|
skip-magic-trailing-comma = false
|
|
|
|
line-ending = "lf"
|
|
|
|
# Disable auto-formatting of code examples in docstrings. Markdown,
|
|
# reStructuredText code/literal blocks and doctests are all supported.
|
|
docstring-code-format = false
|