Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Open
Copy link
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
fromtypingimportIteratorclassX: def__iter__(self) ->Iterator[str]: returniter([""]) deffunc(*args: int) ->None: returnNonefunc(*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