Skip to content

Commit 25165de

Browse files
PeterJCLawmkurnikov
authored andcommitted
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.
1 parent 2295b14 commit 25165de

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

django-stubs/db/models/base.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union, ClassVar, Sequence, Generic
22

33
from django.db.models.manager import Manager
4+
from django.db.models.options import Options
45

56
class ModelBase(type): ...
67

@@ -10,7 +11,7 @@ class Model(metaclass=ModelBase):
1011
class DoesNotExist(Exception): ...
1112
class MultipleObjectsReturned(Exception): ...
1213
class Meta: ...
13-
_meta: Any
14+
_meta: Options
1415
_default_manager: Manager[Model]
1516
pk: Any = ...
1617
def __init__(self: _Self, *args, **kwargs) -> None: ...

django-stubs/db/models/deletion.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from typing import Any, Callable
1+
from typing import Any, Callable, Iterable
22

33
from django.db import IntegrityError
4+
from django.db.models.fields import Field
5+
from django.db.models.options import Options
46

57
def CASCADE(collector, field, sub_objs, using): ...
68
def SET_NULL(collector, field, sub_objs, using): ...
@@ -9,6 +11,8 @@ def DO_NOTHING(collector, field, sub_objs, using): ...
911
def PROTECT(collector, field, sub_objs, using): ...
1012
def SET(value: Any) -> Callable: ...
1113

14+
def get_candidate_relations_to_delete(opts: Options) -> Iterable[Field]: ...
15+
1216
class ProtectedError(IntegrityError): ...
1317

1418
class Collector:

0 commit comments

Comments
 (0)