django-ninja
django-ninja copied to clipboard
Django-ninja doesn't work with mypy?
Hi,
I'm trying to start a new project using django-ninja.
I installed mypy, wanted to see how it works with django-ninja... But somehow I can't make it work together. Mypy correctly checks Pydantic models, but it doesn't work with Django-ninja schemas (even though they inherit pydantic.BaseModel).
Here is a little example with pydantic and django-ninja models instantiated incorrectly:
import ninja
import pydantic
class N(ninja.Schema):
v: int
class P(pydantic.BaseModel):
v: int
n = N(v="z")
p = P(v="z")
Mypy notices an error when creating P, but doesn't whine about incorrect creation of N:
aaa.py:14: error: Argument "v" to "P" has incompatible type "str"; expected "int" [arg-type]
Found 1 error in 1 file (checked 1 source file)
What am I doing wrong? :|
I'm using: python 3.12.1 django-ninja 1.1.0 pydantic 2.5.3 mypy 1.8.0
related #1050