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'm wondering which is the correct way of annotating __dict__ property. Dict[str, Any] seem quite obvious and is used multiple times in typeshed, but:
__dict__
Dict[str, Any]
from typing import Any, Dict class Test: @property def __dict__(self) -> Dict[str, Any]: return {}
% mypy test.py test.py:5: error: Signature of "__dict__" incompatible with supertype "object"
The text was updated successfully, but these errors were encountered:
This appears to be a duplicate of #5836. For example see this minimal repro:
class Test: a = "" # type: str class B(Test): @property def a(self) -> str: return ""
As a workaround in your case, you can likely do something like:
from typing import Dict, Any, TYPE_CHECKING class Test: if TYPE_CHECKING: __dict__ = {} # type: Dict[str, Any] else: @property def __dict__(self) -> Dict[str, Any]: return {}
and mypy should be happy.
Sorry, something went wrong.
#5836 was closed, but this still does not seem to be fixed in mypy 0.812 (Python 3.9.4). Am I missing something here?
No branches or pull requests
I'm wondering which is the correct way of annotating
__dict__
property.Dict[str, Any]
seem quite obvious and is used multiple times in typeshed, but:The text was updated successfully, but these errors were encountered: