Skip to content

Final nested inside ClassVar results in AnyΒ #19607

@hovsater

Description

@hovsater

Bug Report

According to the Python 3.13 ClassVar documentation, ClassVar can be nested within Final, and Final can likewise be nested within ClassVar.

Changed in version 3.13: ClassVar can now be nested in Final, and vice versa.

However, Mypy seems to type-check only the case where ClassVar is nested inside Final, not the reverse.

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.13&flags=strict&gist=996a968ac738badee42e71c23bd5f539

Expected Behavior

Success: no issues found in 1 source file

Actual Behavior

main.py:7: error: Returning Any from function declared to return "int"  [no-any-return]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: mypy 1.17.1 (compiled: yes)
  • Mypy command-line flags: --strict
  • Python version used: Python 3.13.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-finalPEP 591

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions