Skip to content

mypy fails to correctly understand some iterable type in *args #19662

@randolf-scholz

Description

@randolf-scholz
class MyList(list[int]): ...

def test(x: MyList, y: list[int]) -> None:
    reveal_type( [*x] )  # list[Any] ❌
    reveal_type( [*y] )  # list[int] ✅

[*x] should infer as list[int].

https://mypy-play.net/?mypy=latest&python=3.12&gist=5ed11116bf41c5aa803adc3f9333a125

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions