Apologies for the lengthy title.
Describe the bug
I get the following error on application start:
NameError: name 'MySchema' is not defined
If the following conditions are met:
- An endpoint function is defined with the
paginate decorator
- There is an argument to the function that is a user defined query param schema (
Query[MySchema])
- The
from __future__ import annotations import is present in the file
If any of these three things are excluded, the bug does not occur.
Versions (please complete the following information):
- Python versions tested: 3.11, 3.12, 3.13
- Django version: 5.1.6
- Django-Ninja version: 1.3.0
- Pydantic version: 2.10.6
Here is an MRE:
from __future__ import annotations
from ninja import NinjaAPI, Query, Schema
from ninja.pagination import PageNumberPagination, paginate
class MySchema(Schema):
foo: str
api = NinjaAPI()
@api.get("/endpoint_path", response=list[int])
@paginate(PageNumberPagination)
def atpath(
request,
params: Query[MySchema],
):
return []
Apologies for the lengthy title.
Describe the bug
I get the following error on application start:
If the following conditions are met:
paginatedecoratorQuery[MySchema])from __future__ import annotationsimport is present in the fileIf any of these three things are excluded, the bug does not occur.
Versions (please complete the following information):
Here is an MRE: