Skip to content

Honor displayType='always' on first pitch too - #1996

Merged
mscuthbert merged 2 commits into
masterfrom
first-note-naturals
Aug 6, 2026
Merged

Honor displayType='always' on first pitch too#1996
mscuthbert merged 2 commits into
masterfrom
first-note-naturals

Conversation

@mscuthbert

Copy link
Copy Markdown
Member

First note in piece/part w/ explicit natural set with displayType='always', like tinyNotation Cn was being ignored. Fixed.

updateAccidentalDisplay was short circuiting early if there was no pitchPastAll -- so first note had no way of having its "always" or "even-tied" status read.

See same error in music21j: cuthbertLab/music21j#326

AI-assisted (Claude)

Pitch.updateAccidentalDisplay checked cautionaryAll and a displayType of
'always'/'even-tied' only after the `if not pitchPastAll:` early return, so
the first pitch of a part -- the one case with nothing in the past -- never
reached it and fell through to the key-signature branch instead. An
explicitly requested accidental was silently switched off whenever the key
signature made it redundant, and since MusicXML export gates on
displayStatus, it was dropped from the exported file entirely.

Hoist the block above the early return. When pitchPastAll is non-empty this
is a no-op: the only thing it now precedes is the conflict loop, whose two
outcomes (conflicting alteration -> True, same name -> break into this
block -> True) both already ended in True.

Port of the same fix in music21j (cuthbertLab/music21j#325).

Version bumped to invalidate cached pickles: the musedata parser sets
displayType='always', so cached scores can hold the old display statuses.

AI-assisted (Claude)
Doctests demonstrate future usage, not bug fixes -- regression coverage
belongs in test_pitch.py, where testDisplayTypeAlwaysWithNothingInPast
already covers this. A simple bug fix does not warrant a "Changed in vXX"
marker either.

Also: the previous commit's stated reason for the version bump was wrong.
It claimed cached musedata pickles could hold stale display statuses, but
musedata/__init__.py sets displayStatus=True alongside displayType='always',
so updateAccidentalDisplay returns at the existing displayStatus check well
before the hoisted block, and makeAccidentals does not pass overrideStatus.
No parsed output changes and no cache is invalidated. The bump to 11.0.0b8
stands only on the ordinary bug-fix rule.

AI-assisted (Claude)
@mscuthbert mscuthbert added the bug label Aug 6, 2026
@mscuthbert mscuthbert closed this Aug 6, 2026
@mscuthbert mscuthbert reopened this Aug 6, 2026
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.308%. remained the same — first-note-naturals into master

@mscuthbert
mscuthbert merged commit 8707fb6 into master Aug 6, 2026
7 checks passed
@mscuthbert
mscuthbert deleted the first-note-naturals branch August 6, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants