Skip to content

Commit

Permalink
fixing type-A errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mscuthbert committed Jul 28, 2024
1 parent 87702e1 commit a7058e5
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion music21/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def style(self) -> Style:
return self._style

@style.setter
def style(self, newStyle: Style|None):
def style(self, newStyle: Style):
self._style = newStyle

# convenience.
Expand Down
2 changes: 1 addition & 1 deletion music21/braille/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def metronomeMarkToBraille(music21MetronomeMark):
metroNote = note.Note('C4', quarterLength=music21MetronomeMark.referent.quarterLength)
brailleNote = noteToBraille(metroNote, showOctave=False)
metroTrans.append(brailleNote)
englishJoined = ' '.join(metroNote.editorial.get(brailleEnglish, []))
englishJoined = ' '.join(metroNote.editorial.get('brailleEnglish', []))
music21MetronomeMark.editorial.brailleEnglish.append(
f'Metronome Note {englishJoined}'
)
Expand Down
3 changes: 2 additions & 1 deletion music21/chord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4194,7 +4194,8 @@ def setColor(self, value, pitchTarget=None):
'''
# assign to base
if pitchTarget is None and self._notes:
self.style.color = value
chord_style = self.style
chord_style.color = value
for n in self._notes:
n.style.color = value

Expand Down
2 changes: 1 addition & 1 deletion music21/derivation.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def chain(self) -> Generator[base.Music21Object, None, None]:
>>> list(s3.derivation.chain()) == [s2, s1]
True
'''
orig: Music21Object | None = self.origin
orig: base.Music21Object | None = self.origin
while orig is not None:
yield orig
orig = orig.derivation.origin
Expand Down
1 change: 0 additions & 1 deletion music21/meter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1840,4 +1840,3 @@ def offsetToDepth(self, qLenPos, align='quantize', index: int|None = None):
if __name__ == '__main__':
import music21
music21.mainTest()

2 changes: 1 addition & 1 deletion music21/stream/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7987,7 +7987,7 @@ def flatten(self: StreamType, retainContainers=False) -> StreamType:
sNew_derivation.method = method

sNew.derivation = sNew_derivation

# storing .elements in here necessitates
# create a new, independent cache instance in the flat representation
sNew._cache = {}
Expand Down
68 changes: 34 additions & 34 deletions music21/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,45 +102,25 @@ def __init__(self) -> None:
self.dashLength: float|int|None = None
self.spaceLength: float|int|None = None

def _getEnclosure(self) -> Enclosure|None:
return self._enclosure

def _setEnclosure(self, value: Enclosure|None):
if value is None:
self._enclosure = value
elif value == Enclosure.NONE:
self._enclosure = None
elif isinstance(value, Enclosure):
self._enclosure = value
elif isinstance(value, str):
try:
enc_value = Enclosure(value.lower())
except ValueError as ve:
raise TextFormatException(f'Not a supported enclosure: {value!r}') from ve

self._enclosure = enc_value

else:
raise TextFormatException(f'Not a supported enclosure: {value!r}')

enclosure = property(_getEnclosure,
_setEnclosure,
doc='''
@property
def enclosure(self) -> Enclosure|None:
'''
Get or set the enclosure as a style.Enclosure enum or None.
Valid names are
"rectangle"/style.Enclosure.RECTANGLE,
"square"/style.Enclosure.SQUARE,
"oval"/style.Enclosure.OVAL,
"circle"/style.Enclosure.CIRCLE,
"bracket"/style.Enclosure.BRACKET,
"inverted-bracket"/style.Enclosure.INVERTED_BRACKET (output in musicxml 4 only)
None/"none"/style.Enclosure.NONE (returns Python None object)
Valid names are:
* "rectangle"/style.Enclosure.RECTANGLE,
* "square"/style.Enclosure.SQUARE,
* "oval"/style.Enclosure.OVAL,
* "circle"/style.Enclosure.CIRCLE,
* "bracket"/style.Enclosure.BRACKET,
* "inverted-bracket"/style.Enclosure.INVERTED_BRACKET (output in musicxml 4 only)
* None/"none"/style.Enclosure.NONE (returns Python None object)
or the following other shapes with their ALLCAPS Enclosure equivalents:
triangle, diamond,
pentagon, hexagon, heptagon, octagon,
triangle, diamond, pentagon, hexagon, heptagon, octagon,
nonagon, or decagon.
>>> tst = style.TextStyle()
Expand Down Expand Up @@ -172,7 +152,27 @@ def _setEnclosure(self, value: Enclosure|None):
Traceback (most recent call last):
music21.style.TextFormatException:
Not a supported enclosure: 4
''')
'''
return self._enclosure

@enclosure.setter
def enclosure(self, value: Enclosure|None):
if value is None:
self._enclosure = value
elif value == Enclosure.NONE:
self._enclosure = None
elif isinstance(value, Enclosure):
self._enclosure = value
elif isinstance(value, str):
try:
enc_value = Enclosure(value.lower())
except ValueError as ve:
raise TextFormatException(f'Not a supported enclosure: {value!r}') from ve

self._enclosure = enc_value

else:
raise TextFormatException(f'Not a supported enclosure: {value!r}')

def _getAbsoluteY(self):
return self._absoluteY
Expand Down

0 comments on commit a7058e5

Please sign in to comment.