Skip to content

Swapping some type variables gives incorrect results #20336

@randolf-scholz

Description

@randolf-scholz

Two related issues (#19444 and #19362) were fixed in #19449, but I discovered that swapping type variables still gives incorrect results if the generic type contains some additional optional type variables.

class Foo[X, Y, Z=object]:
    def test(self, swapped: Foo[Y, X]) -> None:
        reveal_type(swapped)  # "Foo[X`1, Y`2, builtins.object]" ❓️❗️

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions