Skip to content

nightly-0f85f9e2-ls3

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 02 Nov 11:15
· 18 commits to nightly since this release

CI

Test report · Build status

LinuxServer changes

No changes

Upstream changes

Source: beetbox/beets@0f85f9e

Lint: enable eradicate and flake8-simplify (#7147)

Enable ERA and SIM ruff rules across the codebase 🧹

This turns on two more ruff rule families, ERA (eradicate,
commented-out code) and SIM (flake8-simplify), and fixes everything
they flag in beets/, beetsplug/ and test/. Apart from the two
small exceptions under Notes, behaviour doesn't change. The goal is to
make the linter catch dead code and nested-if / try: ... except: pass boilerplate so reviewers don't have to.

Key Changes

1. Remove commented-out code (ERA) 🪦

  • Change: Deleted stale commented-out code: unused penalty_string
    call in beets/ui/commands/import_/display.py, play_simple, bpm,
    unused mp3gain fields and exc_watcher.join() in replaygain,
    debugging prints and time.sleep in tests, dead assertions in
    test_ui.py and test_types_plugin.py.
  • Change: Moved the "safe mocks" example in
    test/plugins/test_art.py into the docstring as a doctest-style
    example.
  • Change: Where a comment only looks like code (# Reimport, the
    date_time is (...) explanation in beets/importer/tasks.py, the
    mimetype TODO in beetsplug/aura.py), it's kept and marked with # noqa: ERA001.

2. Fix Yoda conditions (SIM300) 🧙

  • Change: "expected" == actual is now actual == "expected". This
    is mostly in tests (test_bpd.py, test_types.py, test_spotify.py
    and others), plus a few spots in beets/dbcore/query.py and
    beetsplug/_utils/requests.py.

3. Apply flake8-simplify (SIM) ✂️

  • Change: These patterns were rewritten mechanically:
Pattern Before After
Nested if (SIM102) if a: / if b: if a and b:
if/else assignment (SIM108) four-line if/else ternary
try/except: pass (SIM105) try: ... except X: pass `with
contextlib.suppress(X):`
Loop returning bool (SIM110) for ...: if ...: return True /
return False any(...)
Return bool (SIM103) if cond: return False / return True
return not cond
Nested with (SIM117) nested with / async with
parenthesised multi-item with
.keys() membership/iteration (SIM118) for k in d.keys() `for
k in d`
str.split() literals (SIM905) "ipfs add -q -r".split()
["ipfs", "add", "-q", "-r"]
  • Change: SIM108 is suppressed in beets/dbcore/query.py and
    beets/util/layout.py, and SIM115 in beetsplug/export.py, where the
    rewrite would read worse or the file deliberately stays open past the
    expression.

Tests 🧪

  • Test code is only touched for lint fixes (Yoda conditions, nested
    with, contextlib.suppress, removed dead code).
  • One previously commented-out assertion in
    test/plugins/test_types_plugin.py::test_date_modify_and_query
    (mydate:1999-12-30) is now active again. It used to be disabled with
    FIXME some sort of timezone issue here.

Notes 📝

  • Behaviour change in playlist query: beetsplug/playlist.py now
    reads the playlist inside with open(...). The file is always closed,
    and an OSError raised while reading (not just while opening) now skips
    to the next playlist instead of propagating.
  • Behaviour change in util.move: the temporary file copy in
    beets/util/__init__.py now uses a single with block for both files,
    with delete=False kept. The resulting file is the same.
  • Re-enabled timezone assertion: see Tests. If it's flaky in CI, it
    should be reverted to the commented-out state rather than worked around.