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

Convert allow_mutation to frozen in model config #161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

camillol
Copy link

@camillol camillol commented Apr 7, 2024

This is a mechanical transformation that is currently done for fields but not for model configs.

@@ -38,6 +37,7 @@
"orm_mode": "from_attributes",
"schema_extra": "json_schema_extra",
"validate_all": "validate_default",
"allow_mutation": "frozen",
Copy link
Member

Choose a reason for hiding this comment

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

Since we are going to check the same "allow_mutation" value again, there's no need to include it in this dictionary.

Comment on lines +175 to +180
if node.target.value == "allow_mutation":
# The `allow_mutation` keyword is the negative of `frozen`.
if m.matches(value, m.Name(value="False")):
value = cst.Name("True")
elif m.matches(value, m.Name(value="True")):
value = cst.Name("False")
Copy link
Member

Choose a reason for hiding this comment

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

We can have this as an elif in the above conditional.

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.

None yet

2 participants