Skip to content

pyrefly raises on iter on Mapping #1055

@MarcoGorelli

Description

@MarcoGorelli
from typing import Mapping, TypeAlias

B: TypeAlias = Mapping[str, int]

def func(a: Mapping[str, str] | B) -> None:
    _ = next(iter(a.items()))
ERROR No matching overload found for function `iter` [no-matching-overload]
 --> /home/marcogorelli/scratch/t.py:6:18
  |
6 |     _ = next(iter(a.items()))
  |                  ^^^^^^^^^^^
  |
  Possible overloads:
  (object: SupportsIter[_SupportsNextT_co], /) -> _SupportsNextT_co [closest match]
  (object: _GetItemIterable[_T], /) -> Iterator[_T]
  (object: () -> _T | None, sentinel: None, /) -> Iterator[_T]
  (object: () -> _T, sentinel: object, /) -> Iterator[_T]
 INFO 1 error
pyrefly 0.31.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    UserBugs reported by external users that should be prioritisedtypechecking

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions