-
Notifications
You must be signed in to change notification settings - Fork 237
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
add dataclass_transform #1054
add dataclass_transform #1054
Conversation
|
||
""" | ||
def decorator(cls_or_fn): | ||
cls_or_fn.__dataclass_transform__ = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use this pattern used in final?
try:
f.__final__ = True
except (AttributeError, TypeError):
# Skip the attribute silently if it is not writable.
# AttributeError happens if the object has __slots__ or a
# read-only property, TypeError if it's a builtin class.
pass
return f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more careful there because we added the behavior later after the decorator was already in the wild, and I didn't want to accidentally break something. Here, we're adding a new decorator, so I think it makes sense to start with the simpler behavior and adjust it only if there's an actual need.
Co-authored-by: Erik De Bonte <erikd@microsoft.com>
Copied from typing-extensions (python/typing#1054, python/typing#1120). Documentation is intentionally omitted, so we can focus on getting the runtime part in before the feature freeze.
Copied from typing-extensions (python/typing#1054, python/typing#1120). Documentation is intentionally omitted, so we can focus on getting the runtime part in before the feature freeze.
From PEP 681.
cc @erictraut @debonte