Open
Description
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
from typing import List, Optional, Tuple
def take_list(the_list: List[Tuple[Optional[int], int]]):
print(the_list)
take_list([(None, 1)]*12) # no error
take_list([(None, 1)]*12*8) # error
take_list([(None, 1)]*(12*8)) # no error
assert [(None, 1)]*12*8 == [(None, 1)]*(12*8) # passes
Expected Behavior
I expect the second function call to not raise an error.
Actual Behavior
The second function call does raise an error.
Your Environment
- Mypy version used: mypy==1.4.1
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files):
# Global options:
[mypy]
warn_return_any = True
warn_unused_configs = True
check_untyped_defs = True
# Per-module options:
[mypy-usb.*]
ignore_missing_imports = True
[mypy-ot_api.*]
ignore_missing_imports = True
[mypy-pylibftdi.*]
ignore_missing_imports = True
- Python version used: 3.10.12
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]Passing a list of[/-][+]Passing a list of tuples with an optional parameter works with 1 multiplier, not 2[/+]SanjayManjunath commentedon Aug 6, 2023
Hey @rickwierenga, I found out that if a Sequence is used instead of List here, the covariance can be ensured since the issue is related to type variance in List. Can you check this out and let me know if it works. https://mypy-play.net/?mypy=latest&python=3.10&gist=be1b241ca37c34bc4ad3b216fc6fe5c4