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

Catch accidental usages of mutable default state values #658

Merged
merged 9 commits into from
Jul 24, 2024

Conversation

wwwillchen
Copy link
Collaborator

@wwwillchen wwwillchen commented Jul 21, 2024

Fixes #644.

Note: this will raise an exception if someone tries to use a proto type in a state class. Before this, we weren't throwing an exception but we were silently not properly serializing & deserializing the proto state (effectively not updating the proto). We'll need to call this out when we sync downstream, and maybe we should support protos properly, but this is at least more explicit.

@wwwillchen wwwillchen changed the title mutable state check Catch accidental usages of mutable default state values Jul 22, 2024
@wwwillchen wwwillchen marked this pull request as ready for review July 23, 2024 02:39
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.

Looks like an improvement. But I did have a few questions about the implementation.

mesop/dataclass_utils/dataclass_utils_test.py Show resolved Hide resolved
mesop/dataclass_utils/dataclass_utils_test.py Outdated Show resolved Hide resolved
mesop/dataclass_utils/dataclass_utils.py Show resolved Hide resolved
mesop/dataclass_utils/dataclass_utils.py Show resolved Hide resolved
@wwwillchen wwwillchen merged commit 81b75b6 into google:main Jul 24, 2024
3 checks passed
@wwwillchen wwwillchen deleted the mutable_state branch July 24, 2024 05:22
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.

Prevent accidental usage of mutable classes in @me.stateclass
2 participants