Skip to content

False positive when calling tuple constructor under influence of bidirectional type inference #7085

@erictraut

Description

@erictraut

The following should result in no error because of the recently-agreed-upon rules for tuple[Any, ...], but pyright generates an error here because its bidirectional type inference logic "upgrades" the type of tuple(x) from tuple[Any, ...] to tuple[int, ...]. But the latter has different (inconsistent) semantics because of the recent rule change about tuple[Any, ...].

def f(x: Iterable[Any]):
    a: tuple[int, int] = tuple(x)  # Should not generate error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions