-
-
Notifications
You must be signed in to change notification settings - Fork 463
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
Update models's fields' _Choices type #2476
Conversation
c104ea7
to
3531bd4
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.
I see you made another release now – would be great if this made the cut for the next one! |
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.
The only question I have is about type params to fields.
3531bd4
to
1484eb6
Compare
Yeah good point, that shouldn't be necessary. Updated! |
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.
Sorry, I've missed to comment on them during the prev review :(
FIRST = 1, "bar" | ||
SECOND = 2, "bar" | ||
|
||
char1 = models.CharField[str, str](max_length=5, choices=TextChoices, default="foo") |
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.
The same question about these ones.
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.
Hah, no worries – I could have looked through for those myself, too!
1484eb6
to
7c5eaae
Compare
But this last change seems to break pyright tests? |
Ok, that's unfortunate. Let's move this test to mypy test only, because we don't officially support pyright and I don't know anything about how it works :( |
Cool! How do I make a test mypy only? 😅 |
You move it to |
Django 5 allows model field choices to be callables, mappings or subclasses of models.Choices. This commit introduces these options in the stubs. Co-Authored-By: Stian Jensen <[email protected]>
7c5eaae
to
c473f88
Compare
Thanks for the help and patience! Here's a new attempt, with proving a couple invalid cases first, then all the succesful asserts, all in a yaml test case for mypy! |
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!
Django 5 allows model field choices to be callables, mappings or subclasses of models.Choices. This commit introduces these options in the stubs.
Continuation of #2368, to fix a merge conflict, avoid issues with importing
Tuple
instead of usingtuple
, and avoid unnecessary formatting changes.