python / python/mypy

`closed=True` should not be supported for Python <3.15

Open
#21,747 2 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.