mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-12 23:16:31 +08:00
Add QuerySet.__aiter__() (#1136)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
AsyncIterator,
|
||||||
Collection,
|
Collection,
|
||||||
Dict,
|
Dict,
|
||||||
Generic,
|
Generic,
|
||||||
@@ -167,6 +168,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized):
|
|||||||
def db(self) -> str: ...
|
def db(self) -> str: ...
|
||||||
def resolve_expression(self, *args: Any, **kwargs: Any) -> Any: ...
|
def resolve_expression(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||||
def __iter__(self) -> Iterator[_Row]: ...
|
def __iter__(self) -> Iterator[_Row]: ...
|
||||||
|
def __aiter__(self) -> AsyncIterator[_Row]: ...
|
||||||
def __contains__(self, x: object) -> bool: ...
|
def __contains__(self, x: object) -> bool: ...
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(self, i: int) -> _Row: ...
|
def __getitem__(self, i: int) -> _Row: ...
|
||||||
|
|||||||
33
tests/typecheck/managers/querysets/test_iteration.yml
Normal file
33
tests/typecheck/managers/querysets/test_iteration.yml
Normal 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
|
||||||
Reference in New Issue
Block a user