The problem is that ParserState.font is typed as str only. In that function, it's temporarily replaced by the result from state.fontset.get_sized_alternatives_for_symbol. That is also only typed as returning str, except for in StixFonts, which overrides it with str | int. So mypy thinks it can never be equal to 0 and the right operand is never used.
Changing ParserState.font to str | int then cascades into every method in the base class that uses it, but maybe that's a good thing? But if I'm not mistaken, the fontname is all internal to the Fonts subclasses, so it may be possible to rename these to all str.
Activity
QuLogic commented on Apr 2, 2026
The problem is that ParserState.font is typed as str only. In that function, it's temporarily replaced by the result from state.fontset.get_sized_alternatives_for_symbol. That is also only typed as returning str, except for in StixFonts, which overrides it with str | int. So mypy thinks it can never be equal to 0 and the right operand is never used.
Changing ParserState.font to str | int then cascades into every method in the base class that uses it, but maybe that's a good thing? But if I'm not mistaken, the fontname is all internal to the Fonts subclasses, so it may be possible to rename these to all str.
mathtext: Fix type inconsistency with fontmaps