-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
We are having issues with the pandas-stubs repo where the inference for __iter__ is different with iter(...).
With __iter__ we are seeing the right inference while with iter(...)
To Reproduce
from typing import Any, Generic, Never, TypeVar, reveal_type
_T_EXPANDING = TypeVar("_T_EXPANDING")
_T_STR = TypeVar("_T_STR", bound=Series)
class StringMethods(Generic[_T_EXPANDING, _T_STR]):
def __getitem__(self, key: int) -> _T_STR: ...
def __iter__(self) -> Never: ...
class Series:
@property
def str(self) -> StringMethods[Any, Series]: ...
def _0() -> None:
reveal_type(StringMethods().__iter__()) # all 4 type checkers give Never
def _1() -> None:
reveal_type(iter(Series().str)) # mypy: Any, pyright, pyrefly: Never, ty: UnknownExpected Behavior
It is identifying it as Any.
Actual Behavior
We expect Never.
Your Environment
- Mypy version used: mypy 1.19.1 (compiled: yes)
- Mypy command-line flags: mypy test_file.py
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.14
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong