Skip to content

Commit

Permalink
typing, mypy, lost -> list
Browse files Browse the repository at this point in the history
  • Loading branch information
mscuthbert committed Oct 29, 2024
1 parent bfa6e94 commit b92727d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dist/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
To do a release,
1. update the VERSION in _version.py and the single test cases in base.py.
1. update the VERSION in _version.py and the single test case in base.py.
2. run `corpus.corpora.CoreCorpus().cacheMetadata()`.
for a major change that affects parsing run corpus.corpora.CoreCorpus().rebuildMetadataCache()
(20 min on IntelMacbook Air) -- either of these MAY change a
Expand Down
27 changes: 14 additions & 13 deletions music21/musedata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
else:
self.stage = None
# store frequently used values
self._cache = {}
self._cache: dict[str, str|None] = {}

def isRest(self) -> bool:
'''
Expand Down Expand Up @@ -398,9 +398,9 @@ def getBeams(self):
# TODO: need to get slurs from this indication:
# (), {}, []

def _getAdditionalNotations(self):
def _getAdditionalNotations(self) -> str|None:
'''
Return an articulation object or None
Return an articulation string or None
>>> mdr = musedata.MuseDataRecord('C4 12 e u [ .p')
>>> mdr._getAdditionalNotations()
Expand All @@ -420,16 +420,17 @@ def _getAdditionalNotations(self):
except KeyError:
pass

data: str|None
if len(self.src) < 31:
data = None
else:
# accumulate chars 32-43, index 31, 42
data = []
data_list = []
i = 31
while i <= 42 and i < len(self.src):
data.append(self.src[i])
data_list.append(self.src[i])
i += 1
data = ''.join(data).strip()
data = ''.join(data_list).strip()
self._cache['_getAdditionalNotations'] = data
return data

Expand Down Expand Up @@ -578,7 +579,7 @@ class MuseDataRecordIterator:
'''

def __init__(self, src, parent):
self.src = src # the lost of all record lines
self.src = src # the list of all record lines
self.index = 0
self.parent = parent

Expand Down Expand Up @@ -738,7 +739,7 @@ class MuseDataMeasureIterator:
'''

def __init__(self, src, boundaries, parent):
self.src = src # the lost of all record lines
self.src = src # the list of all record lines
self.boundaries = boundaries # pairs of all boundaries
self.index = 0
self.parent = parent
Expand Down Expand Up @@ -1468,11 +1469,11 @@ class MuseDataFile(prebase.ProtoM21Object):
When read, one or more MuseDataPart objects are created and stored on self.parts.
'''
def __init__(self):
self.parts = [] # a lost of MuseDataPart objects
def __init__(self) -> None:
self.parts: list[MuseDataPart] = []

self.filename = None
self.file = None
self.filename: str|None = None
self.file: t.BinaryIO|None = None
self.encoding: str = 'utf-8'

def _reprInternal(self):
Expand Down Expand Up @@ -1550,7 +1551,7 @@ class MuseDataWork(prebase.ProtoM21Object):
A work might consist of one or more files.
'''

def __init__(self):
def __init__(self) -> None:
self.files: list[MuseDataFile] = []
self.encoding: str = 'utf-8'

Expand Down
2 changes: 1 addition & 1 deletion music21/musedata/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _musedataRecordListToNoteOrChord(records, previousElement=None):
post.pitch = records[0].getPitchObject()
else:
# environLocal.printDebug(['attempting chord creation: records', len(records)])
# can supply a lost of Pitch objects at creation
# can supply a list of Pitch objects at creation
post = chord.Chord([r.getPitchObject() for r in records])

# if a chord, we are assuming that all durations are the same
Expand Down
2 changes: 1 addition & 1 deletion music21/repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, **keywords):
super().__init__(**keywords)
# store a text version of this expression
self._textExpression = None
# store a lost of alternative text representations
# store a list of alternative text representations
self._textAlternatives = []
# store a default text justification
self.style.justify = 'center'
Expand Down
2 changes: 1 addition & 1 deletion music21/scale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ def tuneOnePitch(p, dst: list[pitch.Pitch]):
for e in streamObj.recurse().notes: # get notes and chords
if e.isChord:
elementPitches = e.pitches
else: # simulate a lost
else: # simulate a list
elementPitches = [e.pitch]

# store a list of reset chord pitches
Expand Down
2 changes: 1 addition & 1 deletion music21/scale/test_intervalNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def testBasicA(self):
'[(5, Terminus.HIGH), (Terminus.HIGH, 5)]'
)

# in calling get next, get a lost of edges and a lost of nodes that all
# in calling get next, get a list of edges and a list of nodes that all
# describe possible pathways
self.assertEqual(
net.getNext(net.nodes[Terminus.LOW], Direction.ASCENDING),
Expand Down
2 changes: 1 addition & 1 deletion music21/stream/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3768,7 +3768,7 @@ def procCompare(mf_inner, match_inner):
n = note.Note('g#3')
n.quarterLength = 0.5
s.repeatAppend(n, 6)
# post = s.midiTracks # get a lost
# post = s.midiTracks # a list
post = midiTranslate.streamHierarchyToMidiTracks(s)

self.assertEqual(len(post[1].events), 30)
Expand Down

0 comments on commit b92727d

Please sign in to comment.