Set types for on_delete functions (#772)

Set types for on_delete functions so they can be provided as values to
the on_delete attribute of ForeignKey in Pyright's strict mode.
This commit is contained in:
w0rp
2021-12-17 19:20:01 +00:00
committed by GitHub
parent feb0bfa4a6
commit 4a0dd04611

View File

@@ -4,14 +4,45 @@ from django.db import IntegrityError
from django.db.models.base import Model from django.db.models.base import Model
from django.db.models.fields import Field from django.db.models.fields import Field
from django.db.models.options import Options from django.db.models.options import Options
from django.db.models.query import QuerySet
def CASCADE(collector, field, sub_objs, using): ... def CASCADE(
def SET_NULL(collector, field, sub_objs, using): ... collector: "Collector",
def SET_DEFAULT(collector, field, sub_objs, using): ... field: Field[Any, Any],
def DO_NOTHING(collector, field, sub_objs, using): ... sub_objs: QuerySet[Model],
def PROTECT(collector, field, sub_objs, using): ... using: str,
def RESTRICT(collector, field, sub_objs, using): ... ) -> None: ...
def SET(value: Any) -> Callable: ... def SET_NULL(
collector: "Collector",
field: Field[Any, Any],
sub_objs: QuerySet[Model],
using: str,
) -> None: ...
def SET_DEFAULT(
collector: "Collector",
field: Field[Any, Any],
sub_objs: QuerySet[Model],
using: str,
) -> None: ...
def DO_NOTHING(
collector: "Collector",
field: Field[Any, Any],
sub_objs: QuerySet[Model],
using: str,
) -> None: ...
def PROTECT(
collector: "Collector",
field: Field[Any, Any],
sub_objs: QuerySet[Model],
using: str,
) -> None: ...
def RESTRICT(
collector: "Collector",
field: Field[Any, Any],
sub_objs: QuerySet[Model],
using: str,
) -> None: ...
def SET(value: Any) -> Callable[..., Any]: ...
def get_candidate_relations_to_delete(opts: Options) -> Iterable[Field]: ... def get_candidate_relations_to_delete(opts: Options) -> Iterable[Field]: ...
class ProtectedError(IntegrityError): class ProtectedError(IntegrityError):