-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Drop .choices
from model field choices
#369
Drop .choices
from model field choices
#369
Conversation
Hmmm. “I don't think this is really a use case?” is kinda shaky evidence. I agree it seems rather unlikely but maybe some people went out of their way to do so, perhaps copy-pasting in the old versions of the Choices classes as a backport, then never upgrading. it’s probably okay, but this is also a very tiny improvement, especially since the choices attribute is being retained without deprecation. hmm, I’m kinda split on this one. |
Indeed this is more likely. Maybe it's time to have some sort of configuration added to select rules ? I'm thinking of 2 possible ways of doing it:
I agree this is a tiny improvement but since it has been added to django core, I think it's good to push this feature (and I do think it's more user-friendly from an API perspective. |
748a5a1
to
c37e050
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for rebasing after I added the 5.0 support.
Returning to the conversation, I think this would actually be pretty safe. Looking again, I think you were probably right that the chances are slim that anyone actually has a custom class with .choices
. Let’s go ahead as is and fix if anyone reports issues.
I have some comments about expanding the scope, if you wouldn't mind.
Thanks the thorough review, will look into it later this week 👌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, gonna do final edits and merge
@@ -36,7 +36,7 @@ def visit_ImportFrom( | |||
parents: list[ast.AST], | |||
) -> Iterable[tuple[Offset, TokenFunc]]: | |||
if ( | |||
not state.looks_like_migrations_file | |||
state.looks_like_models_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. I think I'll actually split looks_like_models_file
and this change into a separate PR.
Fix missing branch coverage
fd181b4
to
012b5be
Compare
.choices
from model field choices
Fixes #336
This might break if someone designed a custom class with a
choices
property which is not a django enumeration class but I don't think this is really a use case ?The documentation links are not yet valid, I think we have to play the waiting game when this MR seems ready for you.
Cheers