Skip to content

Humdrum Typing and Improvements#1883

Merged
mscuthbert merged 10 commits intomasterfrom
humdrum-typing
May 6, 2026
Merged

Humdrum Typing and Improvements#1883
mscuthbert merged 10 commits intomasterfrom
humdrum-typing

Conversation

@mscuthbert
Copy link
Copy Markdown
Member

@mscuthbert mscuthbert commented May 6, 2026

Wanting to solve #62 (and #1882) means understanding how Humdrum Spine Parsing works, a topic that I last looked at around 2010. So before changing the code to something new, need to get it back up to date. AI-assisted PR to clean up the code:

  1. Type annotations throughout.
  2. Removed legacy patterns — like weakrefs for spineCollection and manual __iter__/__next__/iterIndex, is True/is False checks, _elements private access, class.__class__ swaps without running __init__.
  3. Stop using "position" -- a meaningless term. Use lineNumber (yes, it's 1-based sadly, but that's how it goes). fileLength replaced by numLines property.
  4. Real bar.Repeat objects instead of poking a non-existent Barline.repeatDots.
  5. WeakKeyDictionary humdrumLineNumbers maps M21Objects to their line numbers rather than adding and removing attributes.
  6. Renamed moveDynamicsAndLyricsToStreams → attachNonKernEvents and consolidated a lot of branches (that routine already did much more than just Dynamics and Lyrics).
  7. Tuplet sums use opFrac; redundant integer-ratio fallback removed.
  8. Removed flag attributes isSpineLine, isComment, isGlobal, isReference from HumdrumLine and subclasses; use isinstance() instead and get type narrowing.
  9. Add _reprInternal to most classes (and make remaining also be ProtoM21Objects)
  10. Blank lines (technically illegal in Humdrum, but seen often in practice) are stored so that line numbers between files and eventLists remain constant (-1)

@coveralls
Copy link
Copy Markdown

coveralls commented May 6, 2026

Coverage Status

coverage: 93.07% (+0.02%) from 93.052% — humdrum-typing into master

@mscuthbert mscuthbert merged commit a835a8d into master May 6, 2026
7 checks passed
@mscuthbert mscuthbert deleted the humdrum-typing branch May 6, 2026 01:05
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