Skip to content

closed=True should not be supported for Python <3.15 #21747

Description

@A5rocks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions