Skip to content

style: apply Ruff's remaining automatic fixes - #283

Merged
mkb79 merged 1 commit into
masterfrom
style/ruff-unsafe-fixes
Aug 8, 2026
Merged

style: apply Ruff's remaining automatic fixes#283
mkb79 merged 1 commit into
masterfrom
style/ruff-unsafe-fixes

Conversation

@mkb79

@mkb79 mkb79 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

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 each was read rather than trusted.

before after
findings 230 121
file/rule pairs pinned in the baseline 75 36
files with findings 23 17

⚠️ audible --help changes

Two thirds of the fixes 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:

 activation-bytes  Get activation bytes.
-api               Send requests to an Audible API endpoint
+api               Send requests to an Audible API endpoint.
-library           Interact with library
+library           Interact with library.

activation-bytes already ended in a full stop, so this makes the list consistent rather than changing its style. Compared before and after on the real CLI; the added stop is the only difference.

Whitespace inside strings

W291/W293 strip trailing whitespace, which Ruff marks unsafe because whitespace inside a string is content. 24 of these lines are exactly that — 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; click rewraps help text regardless. audible api --help differs only by the added full stop, confirmed by diffing the output.

Two that are neither cosmetic nor a rewrite

  • _logging.py gains stacklevel=2 on a warn() call, so the warning points at the caller instead of at the logging module. Small, but a real change in what the user sees — and the reason the rule exists.
  • plugins.py has its %-formatted plugin warning turned into an f-string. Same text.

Nine 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 keeps the same behaviour, and nothing in the code base shadows dict.

What is left

121 findings that need judgement rather than a tool: 78 G004 (f-strings in logging calls, which are evaluated even when the level discards them), 12 PLR0917, 10 D205, 6 S101 and a handful of others. G004 is the obvious next piece and deserves its own pass.

Verified

ruff check . and ruff format --check . pass, 56 tests green, and against the live API library list --resolve-podcasts --start-date 2008-01-01 returns the identical result set on this branch and on master in the same window — 918 lines, sorted diff empty.

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.
@mkb79
mkb79 merged commit 5584ff7 into master Aug 8, 2026
7 checks passed
@mkb79
mkb79 deleted the style/ruff-unsafe-fixes branch August 8, 2026 04:43
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