model field values and Combinable errors? #2474
wynnw
started this conversation in
Common issues and solutions
Replies: 1 comment
-
I don't get these Combinable errors when I use mypy==1.7.1 django-stubs==4.2.7 django-stubs-ext==4.2.7 But I definitely don't get some of the nice features of the latest releases. So this must be an issue I should just upgrade django to deal with probably, but I am stuck on LTS releases. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm getting started with mypy/django-stubs, and have run into this category of problem:
A model with an IntegerField gets used as index into an array - say
Will get an error like:
Invalid index type "int | Combinable" for "list[int]"; expected type "int".
I'd like to not use cast() or temporary typehinted variables to deal with this as I've got far too much code to update. Feels like I must be doing something wrong to not have this use case work. I get the same type of Combinable error with DateTimeField's and using datetime methods off of the field.
I know that it's super hard to reproduce these types of issues with big code bases. I'm curious if anyone has run into this type of problem and if there's an easy pattern to use that doesn't require widespread code changes. I'm using mypy 1.13 and django 4.2 and django-stubs 5.1.1, with the pyproject.toml configuration approach.
Beta Was this translation helpful? Give feedback.
All reactions