Skip to content

Iterator[int] not recognised as Hashable #21813

Description

@cmp0xff

Bug Report

Iterator[int] is not recognised as Hashable.

To Reproduce

from collections.abc import Sequence, Hashable

class DataFrame:
    def __setitem__(
        self, key: tuple[slice, Hashable], value: Sequence[int]
    ) -> None: ...

# mypy and ty error, pyrefly and pyright pass
DataFrame().__setitem__((slice(None, None, None), iter([0])), [1])
DataFrame()[:, iter([0])] = [1]

Expected Behavior

error free

Actual Behavior

main.py:9: error: Invalid index type "tuple[slice[Any, Any, Any], Iterator[int]]" for "DataFrame"; expected type "tuple[slice[Any, Any, Any], Hashable]"  [index]
main.py:10: error: Invalid index type "tuple[slice[None, None, None], Iterator[int]]" for "DataFrame"; expected type "tuple[slice[Any, Any, Any], Hashable]"  [index]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

Playground

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