Skip to content

[MNT]: Mypy error #31433

Closed
Closed

Description

@timhoffm

Summary

Mypy released a new version yesterday. Since then it errors with

lib/matplotlib/_mathtext.py:1545: error: Right operand of "or" is never evaluated  [unreachable]
Found 1 error in 1 file (checked 108 source files)

Proposed fix

No response

Activity

  1. QuLogic commented on Apr 2, 2026

    @QuLogic
    Member

    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.

  2. added a commit that references this issue on Apr 2, 2026
    021ffb3
  3. added this to the v3.10.9 milestone on Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions