Add more mypy doc sections on common patterns/pitfalls? #172
johnthagen
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
Can you provide minimal reproducible examples? Cause in example Mixin has no database representation so how you end up with Mixin in filter? |
Beta Was this translation helpful? Give feedback.
2 replies
-
Another case where the Pydantic representation clashes with the ORM usage is: class MyModel(Model):
length: Optional[str] = Text(nullable=True)
query = MyModel.objects.filter(model_class.length.isnull(False))
# error: Item "str" of "Optional[str]" has no attribute "isnull"
# error: Item "None" of "Optional[str]" has no attribute "isnull I'm not actually sure if there is anything that can be done while preserving ergonomics, but there could be some discussion of this in the user guide so people aren't caught off guard, and perhaps point to alternative syntax if people do not want to add |
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
-
When selecting inheritance options, I found I had to use Concrete table inheritance or else
mypy
would throw type errors when mixins were used as inputs to genericQuerySet
s:Also, the Python-style filters seem to trip up
mypy
. This is unfortunate, as I feel like they are a bit easier to use and read.Perhaps these kinds of patterns could be added to the docs with suggested work arounds.
Beta Was this translation helpful? Give feedback.
All reactions