`closed=True` should not be supported for Python <3.15
Open
Nobody has claimed this yet.
bug
topic-typed-dict
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
mypy accepts closed=True on TypedDicts before Python 3.15. I think this should be allowed in typing-only files, but not at runtime.
To Reproduce
from typing import TypedDict
class A(TypedDict, closed=True):
x: int
a: A = {"x": 5, "y": "5"} # E
Expected Behavior
An error when defining A.
Actual Behavior
No error when defining A.
Your Environment
Reproduced in mypy-play.
- Mypy version used: 2.3.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.12
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 with the mypy-play reproduction using a TypedDict and closed=True under Python 3.12, then trace how mypy handles this argument and Python-version checks. Done means closed=True is rejected for Python versions before 3.15 while remaining accepted in typing-only files, with regression coverage for the reported behavior.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100