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

Provide more explicit docs about mutable state default values #653

Merged
merged 3 commits into from
Jul 21, 2024

Conversation

wwwillchen
Copy link
Collaborator

I think the docs before were not vocal enough about avoiding this pitfall. I'm also exploring a way of programmatically safe-guarding against mutable default values, but it's a bit tricky - see #647.

@wwwillchen wwwillchen changed the title Provide stronger warnings about mutable state default values Provide more explicit docs about mutable state default values Jul 20, 2024
Copy link
Collaborator

@richard-to richard-to left a comment

Choose a reason for hiding this comment

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

I think this looks better and clearer.

I did noticed in 3.11, it says dataclass will now check if the data type is hashable when determining if an object is a mutable default value or not.

docs/guides/state_management.md Show resolved Hide resolved
@wwwillchen
Copy link
Collaborator Author

I think this looks better and clearer.

I did noticed in 3.11, it says dataclass will now check if the data type is hashable when determining if an object is a mutable default value or not.

good to know! I think we can try to port this change into dataclass_utils

@wwwillchen wwwillchen merged commit dc7df31 into google:main Jul 21, 2024
3 checks passed
@wwwillchen wwwillchen deleted the warning_state branch July 21, 2024 05:48
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.

2 participants