-
Notifications
You must be signed in to change notification settings - Fork 59
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
Usage with dataclasses and inheritance #375
Comments
I strictly recommend avoid lazy annotations as much as possible. Though it looks more like a python bug. We need to investigate what can be done here |
@tuukkamustonen hello Can you add your traceback? And, if it possible, don't clear real dependency name |
What do you refer to by that?
I'll try to add a real reproducible example. |
I refer to |
Okay, neither of those are in play here. It's just inheriting the Tried to create a minimal reproducible example, but eh eh, but couldn't get it fail. Need to double check my previous code, if I missed anything. Will get back. |
I tried simple thing print(get_type_hints(Child))
print(get_type_hints(Child.__init__)) First line works ok, but second fails. |
So the issue is deep down in Python/dataclasses/typing itself... 🤔 |
Seems to be python/cpython#89687 |
From my perspective, the bug is in |
I know it's a controversial topic (at least historically), but yeah, probably quite widely used. So, if there's a way to support this, do consider. Although, this is a bit of a corner case (ie. dataclasses + future annotations + cross-modules). |
It doesn't allow to avoid cyclical imports, it masquerades them. Al that you mention is potentially a code smell which should be fixed.
|
There was a suggestion to use That indeed works for the example case here. |
I do not see how to use |
Unfortunately, no. Looks like it's dumb as you say, and only returns the object name and not the full qualname (so |
Though, could you use a combination of
Could it combine the information for the two? |
Hey, seems like a well thought-out project 👍🏻
Though, is it supposed to work with dataclasses and inheritance?
diparent.py
:dichild.py
:Raises error:
Dropping the
from __future__ import annotations
indiparent.py
removes the error.(Dataclasses reduce the
__init__
boilerplate greatly, wouldn't want to re-declare parent's dependencies always when inheriting.)The text was updated successfully, but these errors were encountered: