Skip to content

PEP 696: Support earlier type param as default value #20190

@hoodmane

Description

@hoodmane

Bug Report

To Reproduce

type A[S, T=S] = dict[S, T]

a: A[int] = {}
reveal_type(a)

Expected Behavior

note: Revealed type is "builtins.dict[builtins.int, builtins.int]"

Actual Behavior

error: Name "T" is not defined  [name-defined]
note: Revealed type is "builtins.dict[builtins.int, Any]"

Your Environment

  • Mypy version used: mypy 1.18.2 (compiled: yes)
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
python_version = "3.13"
show_error_codes = true
  • Python version used: 3.13

I can't repro in the playground, instead it says:

error: Invalid syntax. Maybe you meant '==' or ':=' instead of '='?; you likely need to run mypy using Python 3.13 or newer  [syntax]

Metadata

Metadata

Assignees

No one assigned

    Labels

    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