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

dataclasses.replace raises exception if InitVars with default argument is not provided #164

Open
anthrotype opened this issue Jan 29, 2021 · 0 comments

Comments

@anthrotype
Copy link

This is the same issue as https://bugs.python.org/issue36470, I open a new issue here for greater visibility.

Basically if one has a dataclass which defines an InitVars with a default value, and then uses dataclasses.replace on an instance without passing the init var as parameter to replace, a ValueError: InitVar '...' must be specified with replace() error is raised.

This is bad, because the InitVar already defines its default value, there's no need to expect a value when using replace().
It makes it impossible to use replace() at the same time as default InitVars.

The fix is trivial and there are already two PRs to upstream cpython dataclasses.

python/cpython#17441
python/cpython#20867

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

No branches or pull requests

1 participant