Skip to content
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

Django-ninja doesn't work with mypy? #1053

Closed
JinLisek opened this issue Jan 17, 2024 · 1 comment
Closed

Django-ninja doesn't work with mypy? #1053

JinLisek opened this issue Jan 17, 2024 · 1 comment

Comments

@JinLisek
Copy link

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

@vitalik
Copy link
Owner

vitalik commented Jan 17, 2024

related #1050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants