-
-
Notifications
You must be signed in to change notification settings - Fork 507
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
Signature inference for attributes inherited from generic dataclasses #1780
base: master
Are you sure you want to change the base?
Conversation
Actually, this is a little more complicated than I first imagined. Just pushed another test; this one fails: from typing import Generic, TypeVar
T = TypeVar("T")
@dataclass
class Z:
z: int # not recognized
@dataclass
class Y(Z, Generic[T]):
y: T
@dataclass
class X(Y[int]):
name: str
foo = 3
price: float
quantity: int = 0.0 When I add
Could use some help because this would be a nice thing to have working. 🙂 |
This is definitely not an easy one. In general it's a pretty bad idea to use Nevertheless I of course appreciate your effort! The failing tests are usually half of the work. I feel like the way to solve this is probably to make it a |
@davidhalter thanks for the quick response! I spent a bit more time looking at this and pushed a slightly less specific fix, which just knows to iterate into On the |
@davidhalter any chance you could take a second look at this PR? It'd still be super helpful for myself + some collaborators. (though I totally understand if you'd prefer not to merge!) The current solution relies on an |
@brentyi Sorry, but I'm choosing not to merge it, because I'm not sure I understand all its implications. So I'm not at all going to close this, because I can probably still use 90% of this and merge it at some point, but for now I won't. The issue mentioned above needs to be addressed first. |
Sounds sensible; appreciate the update! |
Thanks for the great library!
Just patched an issue where dataclasses that also happen to be generics aren't being recognized when climbing the MRO. See example in test file.