-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
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
Fix types of inherited attributes in generic dataclasses #12656
Conversation
This comment has been minimized.
This comment has been minimized.
mypy_primer found some regressions. |
The issue is that we are performing type operations during semantic analysis, when not everything may be correctly set up. We'll need to move any type operations to a later phase. We should probably have an assertion that gets triggered if trying to perform type operations when it's not okay to do so. This would save a lot of debugging. |
Isolated the regression with Home Assistant. Hope that helps. from __future__ import annotations
from dataclasses import dataclass
from typing import Generic, TypeVar
T = TypeVar("T")
@dataclass
class Parent2(Generic[T]):
key: str | None = None
@dataclass
class Child2(Parent2[T]): ...
Child2(key=None) # <-- error
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
The last change does resolve all dataclass regressions I saw with Home Assistant. A bit unfortunate that |
Fixes #12633.