style: apply Ruff's safe autofixes - #282
Merged
Merged
Conversation
The baseline added with #281 recorded 442 findings. 219 of them Ruff can fix on its own without changing behaviour, so this applies them and shrinks the baseline accordingly. Fully gone, 23 rules: the type annotation modernization the project's own target-version already implies (UP006/UP007/UP045, 98 findings), import sorting (I001), docstring formatting (D2xx/D4xx), quote style (Q000), redundant f-strings and conversions (F541, RUF010), and a handful of one-off simplifications (UP009, UP015, UP025, UP032, UP034, UP035, PLR5501, RUF021, RUF022, RUF100). 442 findings -> 230 168 file/rule pairs in the baseline -> 75 29 files with findings -> 23 Nothing was fixed with --unsafe-fixes; those 109 remain untouched because they can change behaviour and deserve to be read one by one. `ruff check --fix` reorders imports, which left `src/audible_cli/__init__.py` unformatted even though it had been clean. It is formatted here and dropped from the formatter's exclude list. The remainder is dominated by G004 (78 f-strings in logging calls), D415 (60 docstring endings) and W291 (24 trailing whitespace), none of which Ruff will fix on its own.
mkb79
added a commit
that referenced
this pull request
Aug 8, 2026
Picks up the 110 findings #282 left behind because they need `--unsafe-fixes`. Ruff calls them unsafe where a fix can alter meaning rather than only layout, so every one of them was read rather than trusted. 230 findings -> 121 75 file/rule pairs in the baseline -> 36 23 files with findings -> 17 Two thirds are D415, a full stop at the end of a docstring's first line. Fifteen of those docstrings belong to click commands, which use them as help text, so `audible --help` now reads "Interact with library." where it read "Interact with library" before. `activation-bytes` already ended in a full stop, so this makes the list consistent rather than changing its style. W291 and W293 strip trailing whitespace. Ruff treats that as unsafe because whitespace inside a string is content, and 24 of these lines are exactly that, spread over the quickstart intro, two click help texts and several docstrings. None of it shows: the intro goes to `secho()` unchanged and a space before a line break is invisible in a terminal, while click rewraps help text anyway. `audible api --help` differs only by the added full stop. Two changes are neither cosmetic nor a rewrite. `_logging.py` gains `stacklevel=2` on a `warn()` call, so the warning now points at the caller instead of at the logging module — a small but real change in what the user sees. And `plugins.py` has its `%`-formatted plugin warning turned into an f-string, which produces the same text. The remaining nine are ordinary rewrites: a set comprehension instead of `set()` around a generator, a bare function reference instead of a lambda that only forwarded to it, a list comprehension instead of `map()` with a lambda, `[*initial, current]` instead of `initial + [current]`, `list(range(...))` instead of a comprehension over it, and `{}` instead of `dict()`. `is_supported_file` is a classmethod, so dropping the lambda around it keeps the same object, and nothing in the code base shadows `dict`. What is left needs judgement, not a tool: 78 G004 (f-strings in logging calls, which evaluate even when the level discards them), 12 PLR0917, 10 D205, 6 S101 and a handful of others.
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.
The baseline from #281 recorded 442 findings. Ruff can fix 219 of them itself without changing behaviour, so this applies them and shrinks the baseline accordingly.
What went
23 rules disappear completely:
UP045(42),UP007(31),UP006(25).Optional[str]→str | None,List[x]→list[x]. The project already targets py311, so this is catching up with its owntarget-version.I001(18)D403(14),D212(8),D202(7),D416(4),D209(3),D201(1)Q000(9)F541(3),RUF010(2),UP015(2),UP025(2),UP034(2), plus one each ofUP009,UP032,UP035(8),PLR5501,RUF021,RUF022,RUF100(4)Partially reduced:
G00479→78,W29130→24,W29318→6,PGH0046→3.What stayed
The remaining 230 are dominated by
G004(78 f-strings in logging calls),D415(60 docstring endings) andW291(24 trailing whitespace). Ruff will not fix those on its own.No
--unsafe-fixes. Those 109 can change behaviour and deserve reading one by one, so they are untouched.Note on the process
The baseline suppresses exactly the findings
--fixis meant to repair, so it was removed for the run and regenerated from what remained afterwards.ruff check --fixreorders imports, which leftsrc/audible_cli/__init__.pyunformatted although it had been clean. It is formatted here and dropped from the formatter's exclude list.pyi_entrypoint.pyis included — it sits in the repository root and the release build uses it. Its change is a single quote style swap.Verified
ruff check .andruff format --check .pass, 56 tests greenlibrary list --resolve-podcasts --start-date 2008-01-01returns the identical result set on this branch and on master when run in the same window — 918 lines, sorted diff emptyget_type_hints, dataclasses or Pydantic in play, and the project requires Python ≥3.11 whereX | Noneis valid at definition time