Signature inference for attributes inherited from generic dataclasses - #1780
Signature inference for attributes inherited from generic dataclasses#1780brentyi wants to merge 5 commits into
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.0When 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.