You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mypy is treating an empty dictionary in a tuple differently than an empty dictionary in other collections when it comes to matching Iterable[Dict[..., ...]].
Expected Behavior
With the given file:
fromtypingimportIterable, Dict, Anydeff(x: Iterable[Dict[str, str]]) ->None:
pass# Lists all work as expectedf([])
f([{}])
f([{"k": "v"}])
# Empty tuple worksf(())
# Tuple of empty dict doesn't workf(({},))
# Tuple with non-empty dict worksf(({"k": "v"},))
and running mypy with --strict you should receive no errors because Tuple[Dict[empty]] should match Iterable[Dict[str, str]].
Actual Behavior
$ mypy --strict testme.py
testme.py:17: error: Argument 1 to "f" has incompatible type "Tuple[Dict[<nothing>, <nothing>]]"; expected "Iterable[Dict[str, str]]"
Found 1 error in 1 file (checked 1 source file)
which is erroring out on this line:
f(({},))
Your Environment
Mypy version used: 0.910
Mypy command-line flags: --strict
Python version used: 3.8.6
Operating system and version: Ubuntu 20.04
This is potentially related to #6613 where an empty collection isn't matching a collection type?
The text was updated successfully, but these errors were encountered:
Bug Report
Mypy is treating an empty dictionary in a tuple differently than an empty dictionary in other collections when it comes to matching
Iterable[Dict[..., ...]]
.Expected Behavior
With the given file:
and running
mypy
with--strict
you should receive no errors becauseTuple[Dict[empty]]
should matchIterable[Dict[str, str]]
.Actual Behavior
which is erroring out on this line:
Your Environment
--strict
This is potentially related to #6613 where an empty collection isn't matching a collection type?
The text was updated successfully, but these errors were encountered: