List[<nothing>] error
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the dictionary comprehension from the issue with the stated Python 3.5.2 and mypy 0.501 environment, comparing the Union[...] and Union[List[datetime], List[float]] annotations. Start by tracing dictionary-comprehension type inference; done means the valid empty-list case no longer reports List[] while incompatible value types remain diagnosed.
Written by the indexing model from the issue text.
Description
Hello,
Already showed this in Gitter and was told to open the issue here.
My env is Win7P+SP1 x64, Py 3.5.2 32b and mypy 0.501.
I have the following situation:
With the following code mypy doesn't return an error (which is correct):
from datetime import datetime, timedelta
data_dic = {idx: []
for idx in range(len(lcl.msgs['DATA_COL_NAMES']) - 1)} # type: Dict[int, List[Union[datetime, float]]]
But with the following code mypy returns a strange error
from datetime import datetime, timedelta
data_dic = {idx: []
for idx in range(len(lcl.msgs['DATA_COL_NAMES']) - 1)} # type: Dict[int, Union[List[datetime], List[float]]]
rtg_main.py:197: error: Value expression in dictionary comprehension has incompatible type List[<uninhabited>]; expected type "Union[List[datetime], List[float]]"
Best regards,
JM
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 54
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python/mypy
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug topic-configuration topic-error-reporting
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100