Skip to content

[PEP 696] default substitution not applied correctly when parametrizing a generic type. #140665

@randolf-scholz

Description

@randolf-scholz

Bug report

Bug description:

PEP 696 allows the default of a type-parameter to depend on other type parameters, however, this substitution is not applied at runtime:

class Bar[T, S=T]: ...

print(Bar[int])  # __main__.Bar[int, T]

The result should be __main__.Bar[int, int]1

This is likely the root cause for #140596. Tested with 3.13.8, 3.14.0 and 3.15.0a1+

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Footnotes

  1. pyright playground, mypy-playground, ty-playground, pyrefly sandbox

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions