Thanks to visit codestin.com Credit goes to github.com
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
I have the following example piece of code
from typing import Any, Dict class P: pass class C(P): pass class A: def __init__(self, x: Dict[P, Any]): pass class B(A): def __init__(self, x: Dict[C, Any]): super().__init__(x)
When running mypy on it, this warning appears:
Argument 1 to "init" of "A" has incompatible type "Dict[C, Any]"; expected "Dict[P, Any]"
Why is this happening? If I do the same, but without using Dict[], ie:
Dict[]
class P: pass class C(P): pass class A: def __init__(self, x: P): pass class B(A): def __init__(self, x: C): super().__init__(x)
I get no complains. I tried using Mapping[] instead of Dict[] but the same warning occurs.
Mapping[]
This happens a lot in the code, as I am subclassing from a Library class, I cannot use cast every time, it's counter productive
Environment
The text was updated successfully, but these errors were encountered:
Duplicate of python/typing#445 and #1114 (see also python/typing#273 (comment))
Sorry, something went wrong.
No branches or pull requests
I have the following example piece of code
When running mypy on it, this warning appears:
Why is this happening? If I do the same, but without using
Dict[]
, ie:I get no complains. I tried using
Mapping[]
instead ofDict[]
but the same warning occurs.This happens a lot in the code, as I am subclassing from a Library class, I cannot use cast every time, it's counter productive
Environment
The text was updated successfully, but these errors were encountered: