-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
randolf-scholz/mypy
#6Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
When unpacking a custom iterable class to build another iterable, mypy does not correctly infer the resulting type i.e. CustomIter[CustomIter[_T]] is equal to CustomIter[_T] (that should not be true)
To Reproduce
Expected Behavior
Nested iterable unpacking type checking works fine when using standard types (e.g. list[list[_T]]) however custom iterable classes should have the same behavior.
Actual Behavior
As presented on the playground proof-of-concept the issue is that mypy does not mark the failure on this incorrectly defined function:
def case_1(iter_of_iter: CustomIter[list[int]]) -> CustomIter[int]:
# Mypy fails
#
# Mypy does not flag that the return type does not match.
# It is `CustomIter[list[int]]` instead of `CustomIter[int]`
return CustomIter.new(*iter_of_iter)
Your Environment
- details available on the playground example.
jmesa85 and jgomezb11
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong