FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add dataclass_transform by JelleZijlstra · Pull Request #1054 · python/typing · GitHub

/ typing Public

add dataclass_transform - #1054

Merged
JelleZijlstra merged 3 commits into
python:masterfrom
JelleZijlstra:pep681
Feb 2, 2022
Merged

add dataclass_transform#1054
JelleZijlstra merged 3 commits into
python:masterfrom
JelleZijlstra:pep681

Conversation

Copy link
Copy Markdown
Member

From PEP 681.

cc @erictraut @debonte


"""
def decorator(cls_or_fn):
cls_or_fn.__dataclass_transform__ = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

JelleZijlstra merged commit 59e5918 into python:master Feb 2, 2022
JelleZijlstra deleted the pep681 branch February 2, 2022 17:46
JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this pull request Apr 23, 2022
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.
JelleZijlstra added a commit to python/cpython that referenced this pull request Apr 26, 2022
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL