Add get_candidate_relations_to_delete (#92)

* Set a precise type for Model._meta

* Add missing 'get_candidate_relations_to_delete' function signature

Fixes https://github.com/mkurnikov/django-stubs/issues/77.
This commit is contained in:
Peter Law
2019-07-01 16:50:01 +01:00
committed by Maxim Kurnikov
parent 2295b14214
commit 25165de80f
2 changed files with 7 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union, ClassVar, Sequence, Generic from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union, ClassVar, Sequence, Generic
from django.db.models.manager import Manager from django.db.models.manager import Manager
from django.db.models.options import Options
class ModelBase(type): ... class ModelBase(type): ...
@@ -10,7 +11,7 @@ class Model(metaclass=ModelBase):
class DoesNotExist(Exception): ... class DoesNotExist(Exception): ...
class MultipleObjectsReturned(Exception): ... class MultipleObjectsReturned(Exception): ...
class Meta: ... class Meta: ...
_meta: Any _meta: Options
_default_manager: Manager[Model] _default_manager: Manager[Model]
pk: Any = ... pk: Any = ...
def __init__(self: _Self, *args, **kwargs) -> None: ... def __init__(self: _Self, *args, **kwargs) -> None: ...

View File

@@ -1,6 +1,8 @@
from typing import Any, Callable from typing import Any, Callable, Iterable
from django.db import IntegrityError from django.db import IntegrityError
from django.db.models.fields import Field
from django.db.models.options import Options
def CASCADE(collector, field, sub_objs, using): ... def CASCADE(collector, field, sub_objs, using): ...
def SET_NULL(collector, field, sub_objs, using): ... def SET_NULL(collector, field, sub_objs, using): ...
@@ -9,6 +11,8 @@ def DO_NOTHING(collector, field, sub_objs, using): ...
def PROTECT(collector, field, sub_objs, using): ... def PROTECT(collector, field, sub_objs, using): ...
def SET(value: Any) -> Callable: ... def SET(value: Any) -> Callable: ...
def get_candidate_relations_to_delete(opts: Options) -> Iterable[Field]: ...
class ProtectedError(IntegrityError): ... class ProtectedError(IntegrityError): ...
class Collector: class Collector: