Add QuerySet.__aiter__() (#1136)

This commit is contained in:
Adam Johnson
2022-08-28 13:15:28 +01:00
committed by GitHub
parent 0635afa57c
commit 74e31c7562
2 changed files with 35 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import datetime
from typing import (
Any,
AsyncIterator,
Collection,
Dict,
Generic,
@@ -167,6 +168,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized):
def db(self) -> str: ...
def resolve_expression(self, *args: Any, **kwargs: Any) -> Any: ...
def __iter__(self) -> Iterator[_Row]: ...
def __aiter__(self) -> AsyncIterator[_Row]: ...
def __contains__(self, x: object) -> bool: ...
@overload
def __getitem__(self, i: int) -> _Row: ...

View File

@@ -0,0 +1,33 @@
- case: sync_for
main: |
from myapp.models import User
for user in User.objects.all():
reveal_type(user) # N: Revealed type is "myapp.models.User"
installed_apps:
- myapp
files:
- path: myapp/__init__.py
- path: myapp/models.py
content: |
from django.db import models
class User(models.Model):
pass
- case: async_for
main: |
from myapp.models import User
async def main():
async for user in User.objects.all():
reveal_type(user) # N: Revealed type is "myapp.models.User"
installed_apps:
- myapp
files:
- path: myapp/__init__.py
- path: myapp/models.py
content: |
from django.db import models
class User(models.Model):
pass