[email protected] regression: Argument 1 to "get" of "Mapping" has incompatible type #6597
Open
Description
I got a new regression from the latest release on a real project: https://github.com/wemake-services/wemake-python-styleguide/blob/master/wemake_python_styleguide/logic/arguments/function_args.py#L125-L126
Error:
wemake_python_styleguide/logic/arguments/function_args.py:126: error: Argument 1 to "get" of "Mapping" has incompatible type "Optional[Any]"; expected "str"
Simplier repro:
from typing import Mapping, Any, Optional
x: Optional[Any]
m: Mapping[str, int]
m.get(x)
# error: Argument 1 to "get" of "Mapping" has incompatible type "Optional[Any]"; expected "str"
So, what do you think: is this a valid error? Because it will work at runtime with no problem. And since it has Any
part in it, sometimes it can even be str
. So, in my app it was working as expected in all cases: if x
is str
and exists in m
- then fine. If not - then just return None
.
I am openning it here, because it looks like a typeshed issue, rather than a mypy issue.