chore: add the shared ruff configuration - #306
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lfops carried 48 Python files without any ruff configuration or hook, the only repository with Python code in that state. Three commits:
chore: add the shared ruff configurationwires 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 intoignore(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.fix: address the ruff findings in the plugins and testsclears the 49 findings that remained.style: apply ruff formatis the first formatter run here, 35 files.Verified:
ruff checkandruff format --checkare 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.fetchoneruff proposesnext(...), 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.