-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Closed as not planned
Copy link
Labels
bugmypy got something wrongmypy got something wrong
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
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong