Replies: 2 comments 9 replies
|
@zzzeek, your second example should type check fine. This was a simple bug in pyright. It will be fixed in the next release. |
8 replies
It doesn't look like what you want was intended -- surely if the intention was to allow a specific overload to be affected there wouldn't be a restriction on decorating at most one overload. So I think the proposed clarification in the PEP text is the way to go. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
from the spec
From reading the above, both myself and a co-developer were led to believe this indicated that a specific overload of a decorator function can enable dataclass_transforms, independently of other function overloads. However this does not seem to be the case at least with pyright.
pyright/pylance's behavior seems to be that the
@dataclass_transformdecorator must be applied to the first mention of a function and that mention only, whether it's an overload or just the function implementation. the dataclass_transform then applies to all occurrences of the function.I'm really not sure if im doing this right or what the intent was, so the script below shows what I can see, if someone can check my work on this, thanks
output for pyright:
All reactions