Skip to content

Add missing re-imports to django.db.models. #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions django-stubs/db/models/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from .base import Model as Model

from .aggregates import Aggregate as Aggregate, Sum as Sum, Variance as Variance, Count as Count, Max as Max
from .aggregates import (
Aggregate as Aggregate,
Avg as Avg,
Count as Count,
Max as Max,
Min as Min,
StdDev as StdDev,
Sum as Sum,
Variance as Variance,
)

from .fields import (
AutoField as AutoField,
Expand Down Expand Up @@ -47,7 +56,12 @@ from .deletion import (
PROTECT as PROTECT,
)

from .query import QuerySet as QuerySet, RawQuerySet as RawQuerySet
from .query import (
Prefetch as Prefetch,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Prefetch and prefetch_related_objects are not yet defined in query.py. Please either add them there, or remove them from here, so that test suite would pass.

QuerySet as QuerySet,
RawQuerySet as RawQuerySet,
prefetch_related_objects as prefetch_related_objects,
)

from .query_utils import Q as Q, FilteredRelation as FilteredRelation

Expand Down
12 changes: 12 additions & 0 deletions django-stubs/db/models/query.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,17 @@ class RawQuerySet(Iterable[_T], Sized):
def resolve_model_init_order(self) -> Tuple[List[str], List[int], List[Tuple[str, int]]]: ...
def using(self, alias: Optional[str]) -> RawQuerySet[_T]: ...

class Prefetch(object):
def __init__(self, lookup: str, queryset: Optional[QuerySet] = None, to_attr: Optional[str] = None) -> None: ...
def __getstate__(self) -> Dict[str, Any]: ...
def add_prefix(self, prefix: str) -> None: ...
def get_current_prefetch_to(self, level: int) -> str: ...
def get_current_to_attr(self, level: int) -> Tuple[str, str]: ...
def get_current_queryset(self, level) -> Optional[QuerySet]: ...

def prefetch_related_objects(model_instances: Iterable[_T], *related_lookups: Union[str, Prefetch]) -> None: ...
def get_prefetcher(instance: _T, through_attr: str, to_attr: str) -> Tuple[Any, Any, bool, bool]: ...

class ModelIterable(Iterable[_T]): ...
class InstanceCheckMeta(type): ...
class EmptyQuerySet(metaclass=InstanceCheckMeta): ...
4 changes: 3 additions & 1 deletion scripts/typecheck_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
'Argument 1 to "bytes"',
'"full_clean" of "Model" does not return a value',
'"object" not callable',
'Item "GenericForeignKey" of "Union[GenericForeignKey, Model, None]" has no attribute "read_by"',
'Item "Model" of "Union[GenericForeignKey, Model, None]" has no attribute "read_by"',
re.compile('Cannot determine type of \'(objects|stuff|specimens|normal_manager)\''),
re.compile(r'"Callable\[\[(Any(, )?)+\], Any\]" has no attribute'),
re.compile(r'"HttpResponseBase" has no attribute "[A-Za-z_]+"'),
Expand Down Expand Up @@ -215,9 +217,9 @@
'or_lookups',
'order_with_respect_to',
'ordering',
'prefetch_related',
'pagination',
# TODO: 'postgres_tests',
# TODO: 'prefetch_related',
'project_template',
'properties',
'proxy_model_inheritance',
Expand Down