Skip to content

Commit

Permalink
Fix aiterator() signature. (#262)
Browse files Browse the repository at this point in the history
Queryset.aiterator() was set up to by annotated as `async () -> Iterator` which implies the call semantics are

```
for obj in await queryset.aiterator():
    ...
```

But what we actually want is

```
async for obj in queryset.aiterator():
   ...
```

Updated signature to match Django
  • Loading branch information
john-parton authored Aug 16, 2024
1 parent 79fd3f9 commit 8a8a805
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django-stubs/db/models/query.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _BaseQuerySet(Generic[_T], Sized):
def __and__(self, other: _BaseQuerySet[_T]) -> Self: ...
def __or__(self, other: _BaseQuerySet[_T]) -> Self: ...
def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ...
async def aiterator(self, chunk_size: int = ...) -> Iterator[_T]: ...
def aiterator(self, chunk_size: int = ...) -> AsyncIterator[_T]: ...
def aggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
async def aaggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
def get(self, *args: Any, **kwargs: Any) -> _T: ...
Expand Down

0 comments on commit 8a8a805

Please sign in to comment.