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

Redefined dataclasses.KW_ONLY by erictraut · Pull Request #5826 · python/typeshed · GitHub

Repository navigation

Redefined dataclasses.KW_ONLY - #5826

Merged
JelleZijlstra merged 3 commits into
python:masterfrom
erictraut:kw_only
Aug 1, 2021
Merged

JelleZijlstra merged 3 commits into
python:masterfrom
erictraut:kw_only

Conversation

Copy link
Copy Markdown
Contributor

It was previously defined as a class instance, but class instances are illegal when used within a type annotation. It needs to be a class or a type alias that refers to a class.

…s instance. Class instances are illegal to use within a type annotation.

hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

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

Makes sense! I'd prefer something like class KW_ONLY: ..., since KW_ONLY is actually an instance of _KW_ONLY_TYPE at runtime, so repurposing it is a little confusing (https://github.com/python/cpython/blob/b6bde9fc42aecad5be0457198d17cfe7b481ad79/Lib/dataclasses.py#L192)

This comment has been minimized.

This comment has been minimized.

Copy link
Copy Markdown
Member

python/mypy#10867 wanted a similar change (cc @tgallant), so sounds like this is the right direction to take to make this feature implementable for type checkers.

There's some CI failures though; you'll probably have to add to the stubtest allowlist.

github-actions Bot commented Aug 1, 2021

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

JelleZijlstra merged commit ea4be02 into python:master Aug 1, 2021
tgallant added a commit to tgallant/mypy that referenced this pull request Aug 5, 2021
tgallant added a commit to tgallant/mypy that referenced this pull request Aug 7, 2021
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL