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
{{ message }}
Repository navigation
Can't infer T where T is Mapping[str, int] or Mapping[K, V], but works for sequence #7727
Are you reporting a bug, or opening a feature request?
bug
Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
a.py:23: error: Incompatible return value type (got "object", expected "Mapping[str, int]")
What is the behavior/output you expect?
No error.
Interestingly, there is no error if empty_mapping returns Mapping[str, V] (or Mapping[str, int]), but there is still an error if it returns Mapping[K, int].
What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
mypy --version is mypy 0.740+dev.222b14d904a0e359bec934fd81d67d981abdada4 python --version is Python 3.7.4
What are the mypy flags you are using? (For example --strict-optional)
Activity
ilevkivskyi commentedon Oct 18, 2019
This is actually related to the fact that
Mappingis invariant in key type (but not in value type as you observe).So this is essentially a duplicate of python/typing#445
ilevkivskyi commentedon Oct 18, 2019
Note that #6613 when applied to mapping key type will also solve this I think.