From 08cd3db84761d1cc840a0f209cd30ea2ccd80b70 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sat, 3 Aug 2024 16:01:26 -0400 Subject: [PATCH] fixup! Export fix possibly-used-before-assignment --- music21/musicxml/m21ToXml.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/music21/musicxml/m21ToXml.py b/music21/musicxml/m21ToXml.py index 839456cc3..ea2c7dc04 100644 --- a/music21/musicxml/m21ToXml.py +++ b/music21/musicxml/m21ToXml.py @@ -4103,12 +4103,13 @@ def noteToXml(self, n: note.GeneralNote, noteIndexInChord=0, chordParent=None): n = t.cast(note.NotRest, n) stemDirection = n.stemDirection - if stem_has_style := (chordOrN.hasStyleInformation - and isinstance(chordOrN.style, style.NoteStyle) - and chordOrN.style.stemStyle is not None): - note_style = chordOrN.style + stem_style = None + if (chordOrN.hasStyleInformation + and isinstance(chordOrN.style, style.NoteStyle) + and chordOrN.style.stemStyle is not None): + stem_style = chordOrN.style.stemStyle - if stemDirection is not None or stem_has_style: + if stemDirection is not None or stem_style: mxStem = SubElement(mxNote, 'stem') if stemDirection is None: if closest_clef := chordOrN.getContextByClass(clef.Clef): @@ -4120,9 +4121,9 @@ def noteToXml(self, n: note.GeneralNote, noteIndexInChord=0, chordParent=None): if sdText == 'noStem': sdText = 'none' mxStem.text = sdText - if stem_has_style: - self.setColor(mxStem, note_style.stemStyle) - self.setPosition(mxStem, note_style.stemStyle) + if stem_style: + self.setColor(mxStem, stem_style) + self.setPosition(mxStem, stem_style) # end Stem