Skip to content

[PEP 696] Assigning to type variables with defaults gives unexpected results #19444

Description

@randolf-scholz

Code sample in pyright playground mypy playground

class Foo[X, Y = object]:
    def test(self) -> None:
        reveal_type(Foo[Y, X]())  # Foo[X`1, X`1]

class Bar[X = object, Y = object]:
    def test(self) -> None:
        reveal_type(Bar[Y, X]())  # Bar[Y`2 = builtins.object, Y`2 = builtins.object]

Expected:

  • Foo[Y@Foo, X@Foo]
  • Bar[Y@Bar, X@Bar]

Related issue: #19362

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions