Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
max-muoto committed Apr 12, 2024
1 parent 4e33f79 commit 6b7d99a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ninja/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,20 @@ def _is_view_func(func: Any) -> TypeGuard[ViewFn[Req, P]]:
pagination_class: Type[PaginationBase] = import_string(settings.PAGINATION_CLASS)

if _is_view_func(func_or_pgn_class):
return inject_pagination(func_or_pgn_class, pagination_class)
return _inject_pagination(func_or_pgn_class, pagination_class)

# Second check is redundant, but `TypeGuard` doesn't narrow the negative case.
# `TypeIs` should resolve this: https://peps.python.org/pep-0742/
if not isnotset and isinstance(func_or_pgn_class, type):
pagination_class = func_or_pgn_class

def wrapper(func: ViewFn[Req, P]) -> PaginatedViewFn[Req, P]:
return inject_pagination(func, pagination_class, **paginator_params)
return _inject_pagination(func, pagination_class, **paginator_params)

return wrapper


def inject_pagination(
def _inject_pagination(
func: ViewFn[Req, P],
paginator_class: Type[PaginationBase],
**paginator_params: Any,
Expand Down Expand Up @@ -234,7 +234,7 @@ def add_api_operation(
) -> None:
response = kwargs["response"]
if is_collection_type(response):
view_func = inject_pagination(view_func, self.pagination_class)
view_func = _inject_pagination(view_func, self.pagination_class)
return super().add_api_operation(path, methods, view_func, **kwargs)


Expand Down

0 comments on commit 6b7d99a

Please sign in to comment.