Skip to content

Commit fd8f93f

Browse files
authored
Type hint fixes (#9)
* Removed type hint for _synthesizerRate (not needed here, since it is already defined globally) * Fixed type hint for getScript * Fixed ProsodyCommand type hints (should be BaseProsodyCommand)
1 parent 3c08005 commit fd8f93f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

addon/globalPlugins/MathCAT/MathCAT.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
CharacterModeCommand,
4949
PhonemeCommand,
5050
IndexCommand,
51-
ProsodyCommand,
51+
BaseProsodyCommand,
5252
SpeechCommand,
5353
SynthCommand,
5454
)
@@ -79,7 +79,7 @@
7979
r"|(?P<content>[^<]+)",
8080
)
8181

82-
PROSODY_COMMANDS: dict[str, ProsodyCommand] = {
82+
PROSODY_COMMANDS: dict[str, BaseProsodyCommand] = {
8383
"pitch": PitchCommand,
8484
"volume": VolumeCommand,
8585
"rate": RateCommand,
@@ -169,7 +169,7 @@ def convertSSMLTextForNVDA(text: str) -> list[str | SpeechCommand]:
169169
if language != nvdaLanguage:
170170
out.append(LangChangeCommand(language))
171171

172-
resetProsody: list[Type["ProsodyCommand"]] = []
172+
resetProsody: list[Type["BaseProsodyCommand"]] = []
173173
# log.info(f"\ntext: {text}")
174174
for m in RE_MATHML_SPEECH.finditer(text):
175175
if m.lastgroup == "break":
@@ -188,13 +188,13 @@ def convertSSMLTextForNVDA(text: str) -> list[str | SpeechCommand]:
188188
out.append(PitchCommand(multiplier=int(m.group(m.lastgroup))))
189189
resetProsody.append(PitchCommand)
190190
elif m.lastgroup in PROSODY_COMMANDS:
191-
command: Type["ProsodyCommand"] = PROSODY_COMMANDS[m.lastgroup]
191+
command: Type["BaseProsodyCommand"] = PROSODY_COMMANDS[m.lastgroup]
192192
if command in supportedCommands:
193193
out.append(command(multiplier=int(m.group(m.lastgroup)) / 100.0))
194194
resetProsody.append(command)
195195
elif m.lastgroup == "prosodyReset":
196196
# for command in resetProsody: # only supported commands were added, so no need to check
197-
command: Type["ProsodyCommand"] = resetProsody.pop()
197+
command: Type["BaseProsodyCommand"] = resetProsody.pop()
198198
out.append(command(multiplier=1))
199199
elif m.lastgroup == "phonemeText":
200200
if usePhoneme:
@@ -293,7 +293,7 @@ def getBrailleRegions(
293293
def getScript(
294294
self,
295295
gesture: KeyboardInputGesture,
296-
) -> Callable[KeyboardInputGesture, None] | None:
296+
) -> Callable[[KeyboardInputGesture], None] | None:
297297
"""
298298
Returns the script function bound to the given gesture.
299299
@@ -550,7 +550,7 @@ def getSpeechForMathMl(
550550
synth: SynthDriver = getSynth()
551551
synthConfig = config.conf["speech"][synth.name]
552552
if synth.name == "espeak":
553-
_synthesizerRate: int = synthConfig["rate"]
553+
_synthesizerRate = synthConfig["rate"]
554554
# log.info(f'_synthesizer_rate={_synthesizer_rate}, get_rate()={getSynth()._get_rate()}')
555555
getSynth()._set_rate(_synthesizerRate)
556556
# log.info(f'..............get_rate()={getSynth()._get_rate()}, name={synth.name}')

0 commit comments

Comments
 (0)