Repository navigation
nightly-0f85f9e2-ls3
Pre-release
Pre-release
·
18 commits
to nightly
since this release
CI
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 inbeets/ui/commands/import_/display.py,play_simple,bpm,
unusedmp3gainfields andexc_watcher.join()inreplaygain,
debuggingprints andtime.sleepin tests, dead assertions in
test_ui.pyandtest_types_plugin.py. - Change: Moved the "safe mocks" example in
test/plugins/test_art.pyinto the docstring as a doctest-style
example. - Change: Where a comment only looks like code (
# Reimport, the
date_time is (...)explanation inbeets/importer/tasks.py, the
mimetypeTODO inbeetsplug/aura.py), it's kept and marked with# noqa: ERA001.
2. Fix Yoda conditions (SIM300) 🧙
- Change:
"expected" == actualis nowactual == "expected". This
is mostly in tests (test_bpd.py,test_types.py,test_spotify.py
and others), plus a few spots inbeets/dbcore/query.pyand
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:
SIM108is suppressed inbeets/dbcore/query.pyand
beets/util/layout.py, andSIM115inbeetsplug/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
playlistquery:beetsplug/playlist.pynow
reads the playlist insidewith open(...). The file is always closed,
and anOSErrorraised 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__.pynow uses a singlewithblock for both files,
withdelete=Falsekept. 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.