Skip to content

Indexing tuple with slice object results in wrong type #9200

Open
@rshin

Description

@rshin

Example:

x = (1, 2, 3)
y = x[1:3]
z = x[slice(1, 3)]
reveal_locals()

Output from mypy:

note: Revealed local types are:
note:     x: Tuple[builtins.int, builtins.int, builtins.int]
note:     y: Tuple[builtins.int, builtins.int]
note:     z: builtins.int

I believe z should also have type Tuple[builtins.int, builtins.int], or at a minimum Tuple[builtins.int, ...].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions