Skip to content

Simplify boolean comparisons - #2006

Merged
mscuthbert merged 2 commits into
masterfrom
simplify_bools
Aug 22, 2026
Merged

Simplify boolean comparisons#2006
mscuthbert merged 2 commits into
masterfrom
simplify_bools

Conversation

@mscuthbert

Copy link
Copy Markdown
Member

Replaces x is True / x is False comparisons with plain truthiness tests across the codebase, plus a few incidental typing annotations and comment typo fixes.

Two of the rewrites were sign flips — is not True and is not False are negations, not truthiness tests — and are fixed in the second commit:

  • m21ToXml.noteToXml: d.isGrace is not Trued.isGrace meant <duration> was written only for grace notes (where MusicXML forbids it) and omitted from every ordinary note, making all MusicXML output invalid. 13 tests caught this.
  • recording.samplesFromRecording: storeFile is not Falsenot storeFile meant the wave file was written only when the caller asked for no file. Not covered by tests (# pragma: no cover).

Full suite passes (5298 tests), ruff check and mypy clean.

AI-assisted (Claude)

`x is not True` and `x is not False` are negations; fcdb678 rewrote both
as bare truthiness tests, flipping their sense.

m21ToXml.noteToXml: `d.isGrace is not True` became `d.isGrace`, so
<duration> was written only for grace notes -- where MusicXML forbids it --
and omitted from every ordinary note. All MusicXML output was invalid.

recording.samplesFromRecording: `storeFile is not False` became
`not storeFile`, so the wave file was written only when the caller asked
for no file, and the `isinstance(storeFile, str)` filename branch became
unreachable. Annotation widened to bool|str to match that branch; the
function is `# pragma: no cover`, so nothing caught this.

AI-assisted (Claude)
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.33% (+0.001%) from 93.329% — simplify_bools into master

@mscuthbert
mscuthbert merged commit 93b49de into master Aug 22, 2026
7 checks passed
@mscuthbert
mscuthbert deleted the simplify_bools branch August 22, 2026 01:57
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