We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
dict
collections.abc.Mapping
Expected Behavior
mypy should have accepted the code, as the key type str | Path is more general than str.
str | Path
str
Your Environment
mypy.ini
The text was updated successfully, but these errors were encountered:
https://mypy.readthedocs.io/en/stable/common_issues.html#invariance-vs-covariance
Sorry, something went wrong.
No branches or pull requests
Bug Report
Consider the following code:
Running mypy on this code with the default options produces the following error:
Changing
dict
tocollections.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 thanstr
.Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: