Skip to content

Commit 1b46ff1

Browse files
authored
Merge pull request #1503 from pradishb/master
fix "Type of "paginate" is partially unknown"
2 parents c904181 + 248c2dc commit 1b46ff1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ninja/pagination.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ async def apaginate_queryset(
173173
} # noqa: E203
174174

175175

176-
def paginate(func_or_pgn_class: Any = NOT_SET, **paginator_params: Any) -> Callable:
176+
def paginate(
177+
func_or_pgn_class: Any = NOT_SET, **paginator_params: Any
178+
) -> Callable[..., Any]:
177179
"""
178180
@api.get(...
179181
@paginate
@@ -200,17 +202,17 @@ def my_view(request):
200202
if not isnotset:
201203
pagination_class = func_or_pgn_class
202204

203-
def wrapper(func: Callable) -> Any:
205+
def wrapper(func: Callable[..., Any]) -> Any:
204206
return _inject_pagination(func, pagination_class, **paginator_params)
205207

206208
return wrapper
207209

208210

209211
def _inject_pagination(
210-
func: Callable,
212+
func: Callable[..., Any],
211213
paginator_class: Type[Union[PaginationBase, AsyncPaginationBase]],
212214
**paginator_params: Any,
213-
) -> Callable:
215+
) -> Callable[..., Any]:
214216
paginator = paginator_class(**paginator_params)
215217
if is_async_callable(func):
216218
if not hasattr(paginator, "apaginate_queryset"):
@@ -281,7 +283,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
281283
self.pagination_class = import_string(settings.PAGINATION_CLASS)
282284

283285
def add_api_operation(
284-
self, path: str, methods: List[str], view_func: Callable, **kwargs: Any
286+
self,
287+
path: str,
288+
methods: List[str],
289+
view_func: Callable[..., Any],
290+
**kwargs: Any,
285291
) -> None:
286292
response = kwargs["response"]
287293
if is_collection_type(response):

0 commit comments

Comments
 (0)