Closed as not planned
Description
Bug Report
Consider the following code:
from pathlib import Path
def mkfiles(spec: dict[str | Path, str]) -> None:
...
spec: dict[str, str] = {
"foo.txt": "Fooey",
"bar.txt": "Bar-y",
}
mkfiles(spec)
Running mypy on this code with the default options produces the following error:
superkey01.py:11: error: Argument 1 to "mkfiles" has incompatible type "Dict[str, str]"; expected "Dict[Union[str, Path], str]" [arg-type]
Changing dict
to collections.abc.Mapping
does not get rid of the error.
Expected Behavior
mypy should have accepted the code, as the key type str | Path
is more general than str
.
Your Environment
- Mypy version used: 1.2.0
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.11.3 on macOS 11.7.2