Skip to content

style: clear the harmless Ruff findings - #287

Merged
mkb79 merged 1 commit into
masterfrom
style/lint-cleanup
Aug 9, 2026
Merged

style: clear the harmless Ruff findings#287
mkb79 merged 1 commit into
masterfrom
style/lint-cleanup

Conversation

@mkb79

@mkb79 mkb79 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Works off the Ruff baseline from #281, taking it from 42 findings to 26. Everything in here is a lint fix; what is left in the baseline needs a real code change.

Rule Change
PGH004 ×3 Blanket # noqa comments spelled out or removed
D205 ×10 Docstrings split into a summary line and a body
D417 **additional_options documented on ConfigFile.add_profile
RUF001 En dash in the --page-size help text is now a hyphen
A001 docs/source/conf.py uses Sphinx' project_copyright alias
A002 Already fixed by #286, entry dropped

The one behaviour change

Two of the three PGH004 findings sat on bare except: clauses in Downloader._postpare, which read the error message off a failed download. A bare except: also swallows KeyboardInterrupt, so they now catch Exception. except OSError would be too narrow: the temp file holds a partial response body, so read_text() can just as well raise UnicodeDecodeError.

That class is still live — cmd_download uses it for covers and PDFs.

On A001

This one looked like a permanent exception rather than debt, since docs/source/conf.py has to set the copyright. It is not: Sphinx has accepted project_copyright as an alias since 3.5, so the variable is simply renamed and the entry is gone. The repo pins no Sphinx version and carries no .readthedocs.yaml, so the docs build against a current release, and nothing else under docs/ refers to the old name.

Docstrings

LibraryItem._get_codec and BrokenCommand gained a summary line above their existing text. The rest were reworded around the split, mostly into the imperative mood the Google convention asks for. Where that rewording would have dropped the fact that the function is a decorator, the summary says so again.

Two typos Copilot spotted in docstrings this touches anyway, "them codecs list" and "build-in", are corrected. The build_in_cmds function keeps its name and so do the two occurrences in plugin_cmds/README.md; a rename is not a lint fix.

What is left

The remaining 26 findings, in the order they are worth tackling: the error and input contracts (B904, S101), the download orchestration (C901, PLW0603, PLW2901, ASYNC240) and finally PLR0917.

Verification

ruff check, ruff format --check and the 56 tests pass. The 42 → 26 count was measured by emptying the baseline block on both master and this branch and counting the findings it suppresses. No changelog entry, matching #282, #283 and #285.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces the Ruff baseline by addressing remaining low-risk lint findings through docstring formatting tweaks, clearer # noqa annotations, and a small exception-handling improvement to avoid swallowing KeyboardInterrupt.

Changes:

  • Convert several docstrings to a summary-line + body format (D205) and document **additional_options on ConfigFile.add_profile (D417).
  • Replace blanket # noqa comments with explicit rule codes and switch two bare except: clauses to except Exception.
  • Small style/lint cleanups: replace an en dash with a hyphen in help text (RUF001) and rename Sphinx config copyright to project_copyright (A001).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
utils/update_chapter_titles.py Docstring reformatted to satisfy D205.
src/audible_cli/utils.py Replaces blanket # noqa with specific codes; changes bare except: to except Exception in downloader post-processing.
src/audible_cli/plugins.py Docstring summary/body split for D205 compliance.
src/audible_cli/models.py Docstring summary/body split for D205 compliance.
src/audible_cli/decorators.py Docstring formatting + help-text punctuation change (RUF001).
src/audible_cli/config.py Documents **additional_options parameter in add_profile docstring (D417).
src/audible_cli/cmds/init.py Docstring summary/body adjustment for D205 compliance.
src/audible_cli/_logging.py Docstring summary/body split for D205 compliance.
pyproject.toml Updates Ruff per-file-ignores baseline entries to reflect reduced findings.
plugin_cmds/convert_oa_cred.py Docstring reformatted to satisfy D205.
docs/source/conf.py Renames copyright to project_copyright to avoid A001.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/audible_cli/models.py Outdated
Comment thread src/audible_cli/cmds/__init__.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (2)

utils/update_chapter_titles.py:1

  • Docstring grammar: use “an” before “ffmetadata” (pronounced “eff”).
"""Replace the chapter titles of a ffmetadata file.

src/audible_cli/_logging.py:142

  • Docstring sentence “That is …” reads ungrammatically here; rephrase to clearly refer to the handler and formatter.
    That is :py:class:`ClickHandler` and :py:class:`ColorFormatter`.

Takes the baseline from 42 findings to 26, leaving only the ones that
need a real code change: the download orchestration (C901, PLW0603,
PLW2901, ASYNC240), the error contracts (B904, S101) and PLR0917.

- PGH004: three blanket `# noqa` comments. The one on `import readline`
  was hiding two rules, F401 and PLC0415, and is now spelled out. The
  two in `Downloader._postpare` sat on bare `except:` clauses, which
  also swallow KeyboardInterrupt while reading the error message off a
  failed download; they now catch Exception. `except OSError` would be
  too narrow, the temp file holds a partial response body and
  read_text() can just as well raise UnicodeDecodeError.
- D205: ten docstrings split into a summary line and a body. Two of
  them, `LibraryItem._get_codec` and `BrokenCommand`, gained a summary
  line above their existing text; the rest were reworded around the
  split, mostly into the imperative mood the Google convention asks
  for. Where that rewording would have dropped the fact that the
  function is a decorator, the summary says so again.
- D417: documented `**additional_options` on `ConfigFile.add_profile`.
- RUF001: an en dash in the `--page-size` help text is now a hyphen.
- A001: `docs/source/conf.py` sets the copyright through Sphinx' own
  `project_copyright` alias, which has been supported since Sphinx 3.5,
  rather than shadowing the builtin.
- A002 needs no entry any more, #286 renamed that parameter.

Two typos in docstrings this touches anyway, "them codecs list" and
"build-in", are corrected. The `build_in_cmds` function keeps its name
and so do the two occurrences in plugin_cmds/README.md; a rename is not
a lint fix.
@mkb79
mkb79 force-pushed the style/lint-cleanup branch from a2b843a to e99c586 Compare August 9, 2026 09:21
@mkb79
mkb79 merged commit 71b8f8e into master Aug 9, 2026
7 checks passed
@mkb79
mkb79 deleted the style/lint-cleanup branch August 9, 2026 10:02
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.

2 participants