@@ -153,7 +153,7 @@ def getSolutionsUsed(self):
153153 post .append (solution )
154154 return post
155155
156- def solutionLegend (self , compress = False ):
156+ def solutionLegend (self , compress : bool = False ) -> list [ list [ str | list [ tuple [ int | str , str | None ]]]] :
157157 '''
158158 A list of pairs showing all discrete results and the assigned color.
159159 Data should be organized to be passed to
@@ -162,7 +162,7 @@ def solutionLegend(self, compress=False):
162162 If `compress` is True, the legend will only show values for solutions
163163 that have been encountered.
164164 '''
165- pass
165+ return []
166166
167167 def solutionUnitString (self ):
168168 '''
@@ -211,7 +211,7 @@ class KeyWeightKeyAnalysis(DiscreteAnalysis):
211211 # favor eb minor
212212 # C- major cannot be determined if no enharmonics are present
213213 # C# major can be determined w/o enharmonics
214- keysValidMajor = (
214+ keysValidMajor : tuple [ str , ...] = (
215215 'C' , 'C#' , 'C-' ,
216216 'D-' , 'D' ,
217217 'E-' , 'E' ,
@@ -221,7 +221,7 @@ class KeyWeightKeyAnalysis(DiscreteAnalysis):
221221 'B-' , 'B' ,
222222 )
223223
224- keysValidMinor = (
224+ keysValidMinor : tuple [ str , ...] = (
225225 'C' , 'C#' ,
226226 'D' , 'D#' ,
227227 'E-' , 'E' ,
@@ -442,7 +442,7 @@ def _getDifference(self, keyResults, pcDistribution, weightType) -> None|list[fl
442442 solution [i ] = float (top [i ] / ((bottomRight [i ] * bottomLeft [i ]) ** 0.5 ))
443443 return solution
444444
445- def solutionLegend (self , compress = False ):
445+ def solutionLegend (self , compress : bool = False ) -> list [ list [ str | list [ tuple [ int | str , str | None ]]]] :
446446 '''
447447 Returns a list of lists of possible results for the creation of a legend.
448448
@@ -478,16 +478,18 @@ def solutionLegend(self, compress=False):
478478 keySortOrderFiltered = _keySortOrder
479479
480480 data = []
481- valid = None
481+ valid : tuple [ str , ...] = ()
482482
483+ yLabel : str
483484 for yLabel in ['Major' , 'Minor' ]:
484485 if yLabel == 'Major' :
485486 valid = self .keysValidMajor
486487 elif yLabel == 'Minor' :
487488 valid = self .keysValidMinor
488489
489- row : list [t .Any ] = [yLabel ]
490- pairs = []
490+ row : list [str | list [tuple [int | str , str | None ]]] = [yLabel ]
491+ pairs : list [tuple [int | str , str | None ]] = []
492+ color : str | None
491493 for keyPitch in [pitch .Pitch (p ) for p in keySortOrderFiltered ]:
492494 try :
493495 color = self .solutionToColor ([keyPitch , yLabel ])
@@ -499,6 +501,7 @@ def solutionLegend(self, compress=False):
499501 mask = True
500502 if keyPitch .name not in valid :
501503 mask = True
504+
502505 if mask :
503506 # set as white to maintain spacing
504507 color = '#ffffff'
@@ -1076,7 +1079,7 @@ def getPitchSpan(self, subStream) -> tuple[pitch.Pitch, pitch.Pitch]|None:
10761079
10771080 return minPitchObj , maxPitchObj
10781081
1079- def solutionLegend (self , compress = False ):
1082+ def solutionLegend (self , compress : bool = False ) -> list [ list [ str | list [ tuple [ int | str , str | None ]]]] :
10801083 '''
10811084 Return legend data.
10821085
@@ -1119,7 +1122,7 @@ def solutionLegend(self, compress=False):
11191122
11201123 data = []
11211124
1122- colors = {} # a filtered dictionary
1125+ colors : dict [ int , str ] = {} # a filtered dictionary
11231126 for i in range (len (self ._pitchSpanColors .keys ())):
11241127 if compress :
11251128 if self ._pitchSpanColors [i ] not in colorsUsed :
@@ -1135,8 +1138,8 @@ def solutionLegend(self, compress=False):
11351138
11361139 # split keys into two groups for two rows (optional)
11371140 for keyGroup in [keysTopRow , keysBottomRow ]:
1138- row : list [t . Any ] = ['' ] # empty row label
1139- pairs = []
1141+ row : list [str | list [ tuple [ int | str , str | None ]] ] = ['' ] # empty row label
1142+ pairs : list [ tuple [ int | str , str | None ]] = []
11401143 for i in keyGroup :
11411144 color = colors [i ] # get form colors
11421145 pairs .append ((i , color ))
@@ -1151,7 +1154,7 @@ def solutionUnitString(self):
11511154 '''
11521155 return 'Half-Steps'
11531156
1154- def solutionToColor (self , solution ) :
1157+ def solutionToColor (self , solution : int | None ) -> str :
11551158 '''
11561159
11571160 >>> p = analysis.discrete.Ambitus()
0 commit comments