-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Custom implemented __iter__
method on class mismatches when passing positional arguments with asterisk(*
)
To Reproduce
from typing import Iterator
class X:
def __iter__(self) -> Iterator[str]:
return iter([""])
def func(*args: int) -> None:
return None
func(*X()) # OK (false positive, should have incompatible type error)
func(*X().__iter__()) # 13: error: Argument 1 to "func" has incompatible type "*Iterator[str]"; expected "int" [arg-type]
Expected Behavior
Mypy should yield an error when passing positional parameters with asterisk(*
) that do not match the expected type.
In this case it should complain on the function call on line 12, as it calls func
with a mismatching type of iterable.
Actual Behavior
Passing iterator with only *
yields no error.
Your Environment
- Mypy version used: 0.991
- Mypy command-line flags: -
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.11
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong