Skip to content

Commit

Permalink
fixed await warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalik committed Apr 30, 2024
1 parent a937981 commit beff2ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions ninja/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ async def evaluate(results: Union[List, QuerySet]) -> AsyncGenerator:
async for result in evaluate(result[paginator.items_attribute])
]
return result

else:

@wraps(func)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_pagination_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ async def apaginate_queryset(self, items, pagination: Input, **params):
skip = pagination.skip
return items[skip : skip + 5]

def _items_count(self, queryset: QuerySet) -> int:
async def _items_count(self, queryset: QuerySet) -> int:
try:
# forcing to find queryset.count instead of list.count:
return queryset.all().count()
except AttributeError:
asyncio.sleep(0)
await asyncio.sleep(0)
return len(queryset)


Expand Down Expand Up @@ -99,7 +99,7 @@ async def test_async_default():
@api.get("/items_default", response=List[int])
@paginate # WITHOUT brackets (should use default pagination)
async def items_default(request, someparam: int = 0, **kwargs):
asyncio.sleep(0)
await asyncio.sleep(0)
return ITEMS

client = TestAsyncClient(api)
Expand Down

0 comments on commit beff2ae

Please sign in to comment.