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

match_args, slots and possibly kw_only missing from __dataclass_params__ #96142

Closed
da-woods opened this issue Aug 20, 2022 · 1 comment
Closed
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@da-woods
Copy link
Contributor

Bug report

Dataclasses have an undocumented __dataclass_params__ class-attribute which appears to document the flags sent to the dataclass decorator:

cpython/Lib/dataclasses.py

Lines 903 to 904 in 6ec57e7

setattr(cls, _PARAMS, _DataclassParams(init, repr, eq, order,
unsafe_hash, frozen))

A few new flags have been added since the initial implementation of dataclasses. These don't seem to have been added to the __dataclass_params__ field. In the case of kw_only I think that makes sense - it's effectively controlled at a per-field level and the parameter to the dataclass decorator is just a convenience. However, the others seem like a genuine omission.

Your environment

I've just looked at the code for the current main branch.

@da-woods da-woods added the type-bug An unexpected behavior, bug, or error label Aug 20, 2022
@AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Aug 20, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Aug 29, 2022
@ericvsmith
Copy link
Member

Thanks, @sobolevn !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants