Skip to content
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

Fixes mypy crash on dataclasses.field(**unpack) #11137

Merged
merged 3 commits into from
Sep 21, 2021
Merged

Fixes mypy crash on dataclasses.field(**unpack) #11137

merged 3 commits into from
Sep 21, 2021

Conversation

sobolevn
Copy link
Member

Closes #10879

@@ -15,7 +20,23 @@ class int: pass
class float: pass
class str: pass
class bool(int): pass
class dict(Generic[_T, _U]): pass

class dict(Mapping[KT, VT]):
Copy link
Member Author

Choose a reason for hiding this comment

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

We need this for **dict unpack.

mypy/plugins/dataclasses.py Outdated Show resolved Hide resolved
test-data/unit/check-dataclasses.test Outdated Show resolved Hide resolved
test-data/unit/check-dataclasses.test Outdated Show resolved Hide resolved
@hauntsaninja hauntsaninja merged commit a7d6e68 into python:master Sep 21, 2021
JukkaL pushed a commit that referenced this pull request Sep 24, 2021
)

Fixes #10248

The crash due to dataclasses.field was fixed in the recent PR #11137, but the error 
message was wrong when positional arguments are used.

I update the error message based on 
#10248 (comment)
(Thanks @JelleZijlstra!)
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.

Dataclasses: field function called with ** (double asterisk, unpack-dictionary) results in internal error
3 participants