`Final` nested inside `ClassVar` results in `Any`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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:
ClassVarcan now be nested inFinal, 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked mypy-play reproducer with Python 3.13 and --strict, then trace how mypy handles the two nesting orders of ClassVar and Final. Add a regression test for Final nested inside ClassVar and verify that the example reports no errors, including no-any-return.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100