Skip to content

chore: add the shared ruff configuration - #306

Merged
markuslf merged 3 commits into
mainfrom
chore/add-ruff
Aug 3, 2026
Merged

chore: add the shared ruff configuration#306
markuslf merged 3 commits into
mainfrom
chore/add-ruff

Conversation

@markuslf

@markuslf markuslf commented Aug 3, 2026

Copy link
Copy Markdown
Member

lfops carried 48 Python files without any ruff configuration or hook, the only repository with Python code in that state. Three commits:

  1. chore: add the shared ruff configuration wires up [tool.ruff] with the same values as the other repositories and moves the bandit skips out of the pre-commit hook arguments into [tool.bandit], so a manual run matches what the hook does. Ansible module boilerplate goes into ignore (DOCUMENTATION above the imports, dict() in argument_spec, the __future__ / __metaclass__ preamble). Vendored ansible-freeipa and python-gnupg code plus the vulture whitelist are excluded so patches stay sendable upstream.
  2. fix: address the ruff findings in the plugins and tests clears the 49 findings that remained.
  3. style: apply ruff format is the first formatter run here, 35 files.

Verified: ruff check and ruff format --check are clean, the vendored files and the vulture whitelist are byte-identical to before, and the unit suite passes (127 tests plus 18 subtests, UBI9 / Python 3.12 / ansible-core 2.18).

One finding was not auto-fixed on purpose. For sqlite_query.fetchone ruff proposes next(...), which raises StopIteration, while the surrounding code caught IndexError to return the empty result. That would have broken the empty-result path, so the list-index form is kept and the empty case handled explicitly.

lfops carried 48 Python files without any ruff configuration or hook, the only repository with Python code in that state. It now uses the same `[tool.ruff]` blocks as the others. Its bandit skips move out of the pre-commit hook arguments into `[tool.bandit]` at the same time, so a manual run matches what the hook does.

Ansible module boilerplate is added to `ignore`: collections put DOCUMENTATION/EXAMPLES/RETURN above the imports, spell argument_spec with `dict()`, and carry the `__future__` / `__metaclass__` preamble that ansible-core documents. Vendored ansible-freeipa and python-gnupg code plus the vulture whitelist are excluded so patches stay sendable upstream.
Preserves the exception chain in the Bitwarden code (`raise ... from e`), marks deliberately unused unpacked bindings with a leading underscore, unpacks instead of concatenating the occ command lists, and annotates the shared recorder attributes of the test stubs as ClassVar.

`sqlite_query.fetchone` is rewritten by hand rather than auto-fixed: ruff proposes `next(...)`, which raises StopIteration, while the surrounding code caught IndexError to return the empty result. The list-index form is kept and the empty case handled explicitly.
First run of the formatter on this repository. No behaviour change.
@markuslf
markuslf merged commit 1ad269a into main Aug 3, 2026
10 checks passed
@markuslf
markuslf deleted the chore/add-ruff branch August 3, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant