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

Add fixer for invalid_list message of ModelMultipleChoiceField #258

Merged

Conversation

UnknownPlatypus
Copy link
Contributor

Fixes #256

Comment on lines +48 to +51
and any(
(isinstance(key, ast.Constant) and (list_node := key).value == "list")
for key in error_message_node.value.keys
)
Copy link
Owner

Choose a reason for hiding this comment

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

I think this is the first time I've seen walrus used inside a comprehension!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's actually a neet trick to find a culprit using the any short circuit behaviour. Not so many use cases thought but it works nicely in this case.

@adamchainz adamchainz changed the title Fixer to replace ModelMultipleChoiceField's list error message with invalid_list Add fixer for invalid_list message of ModelMultipleChoiceField Sep 29, 2022
@adamchainz adamchainz merged commit 3be2527 into adamchainz:main Sep 29, 2022
@adamchainz
Copy link
Owner

Brilliant, thank you for yet another star contribution.

@UnknownPlatypus UnknownPlatypus deleted the forms_model_multiple_choice branch September 29, 2022 08:21
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.

Replace ModelMultipleChoiceField's list error message with invalid_list
2 participants