mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-18 01:45:59 +08:00
better stubs
This commit is contained in:
@@ -1,83 +1,288 @@
|
||||
from django.core.checks.messages import Error, Warning
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import Col
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.fields.reverse_related import (
|
||||
ForeignObjectRel,
|
||||
ManyToOneRel,
|
||||
OneToOneRel,
|
||||
)
|
||||
from django.db.models.query_utils import FilteredRelation, PathInfo
|
||||
from django.forms.models import ModelChoiceField
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||
from uuid import UUID
|
||||
from django.db.models.fields import AutoField
|
||||
from django.db.models.fields.related_lookups import (RelatedExact,
|
||||
RelatedGreaterThan,
|
||||
RelatedGreaterThanOrEqual,
|
||||
RelatedIn, RelatedIsNull,
|
||||
RelatedLessThan,
|
||||
RelatedLessThanOrEqual)
|
||||
from django.db.models.fields.reverse_related import ManyToManyRel, ManyToOneRel
|
||||
from django.db.models.query_utils import Q
|
||||
from django.db.models.sql.where import WhereNode
|
||||
|
||||
class ForeignKey:
|
||||
def __init__(
|
||||
from . import Field
|
||||
from .mixins import FieldCacheMixin
|
||||
from .related_descriptors import (ForwardManyToOneDescriptor,
|
||||
ForwardOneToOneDescriptor,
|
||||
ManyToManyDescriptor,
|
||||
ReverseManyToOneDescriptor,
|
||||
ReverseOneToOneDescriptor)
|
||||
from .related_lookups import (RelatedExact, RelatedGreaterThan,
|
||||
RelatedGreaterThanOrEqual, RelatedIn,
|
||||
RelatedIsNull, RelatedLessThan,
|
||||
RelatedLessThanOrEqual)
|
||||
from .reverse_related import (ForeignObjectRel, ManyToManyRel, ManyToOneRel,
|
||||
OneToOneRel)
|
||||
|
||||
RECURSIVE_RELATIONSHIP_CONSTANT: str
|
||||
|
||||
def resolve_relation(
|
||||
scope_model: Type[Model], relation: Union[Type[Model], str]
|
||||
) -> Union[Type[Model], str]: ...
|
||||
def lazy_related_operation(
|
||||
function: Callable, model: Type[Model], *related_models: Any, **kwargs: Any
|
||||
) -> None: ...
|
||||
|
||||
class RelatedField(FieldCacheMixin, Field):
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
def related_model(self) -> str: ...
|
||||
def check(self, **kwargs: Any): ...
|
||||
def db_type(self, connection: Any): ...
|
||||
opts: Any = ...
|
||||
def contribute_to_class(
|
||||
self,
|
||||
to: Any,
|
||||
on_delete: Callable,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Any = ...,
|
||||
parent_link: bool = ...,
|
||||
to_field: Optional[str] = ...,
|
||||
db_constraint: bool = ...,
|
||||
**kwargs,
|
||||
cls: Type[Model],
|
||||
name: str,
|
||||
private_only: bool = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def _check_on_delete(self) -> List[Any]: ...
|
||||
def _check_unique(self, **kwargs) -> List[Warning]: ...
|
||||
def check(self, **kwargs) -> Union[List[Warning], List[Error]]: ...
|
||||
def contribute_to_related_class(
|
||||
self, cls: Type[Model], related: ManyToOneRel
|
||||
) -> None: ...
|
||||
def db_check(self, connection: DatabaseWrapper) -> List[Any]: ...
|
||||
def db_parameters(self, connection: DatabaseWrapper) -> Dict[str, str]: ...
|
||||
def db_type(self, connection: DatabaseWrapper) -> str: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def formfield(self, *, using=..., **kwargs) -> ModelChoiceField: ...
|
||||
def get_attname(self) -> str: ...
|
||||
def get_attname_column(self) -> Tuple[str, str]: ...
|
||||
def get_col(
|
||||
self,
|
||||
alias: str,
|
||||
output_field: Optional[Union[Field, reverse_related.OneToOneRel]] = ...,
|
||||
) -> Col: ...
|
||||
def get_db_converters(self, connection: DatabaseWrapper) -> List[Any]: ...
|
||||
def get_db_prep_save(
|
||||
self, value: object, connection: DatabaseWrapper
|
||||
) -> Optional[Union[str, int]]: ...
|
||||
def get_db_prep_value(
|
||||
self,
|
||||
value: Union[str, int, UUID],
|
||||
connection: DatabaseWrapper,
|
||||
prepared: bool = ...,
|
||||
) -> Union[str, int]: ...
|
||||
def get_default(self) -> Optional[int]: ...
|
||||
def get_reverse_path_info(
|
||||
self, filtered_relation: Optional[FilteredRelation] = ...
|
||||
) -> List[PathInfo]: ...
|
||||
def deconstruct(
|
||||
self
|
||||
) -> Tuple[None, str, List[Any], Dict[str, Union[str, bool]]]: ...
|
||||
def get_forward_related_filter(self, obj: Any): ...
|
||||
def get_reverse_related_filter(self, obj: Model) -> Q: ...
|
||||
@property
|
||||
def target_field(self) -> Field: ...
|
||||
def to_python(self, value: Union[str, int]) -> Union[str, int]: ...
|
||||
def validate(self, value: int, model_instance: Optional[Model]) -> None: ...
|
||||
def swappable_setting(self) -> Optional[str]: ...
|
||||
name: Any = ...
|
||||
verbose_name: Any = ...
|
||||
def set_attributes_from_rel(self) -> None: ...
|
||||
def do_related_class(
|
||||
self, other: Type[Model], cls: Type[Model]
|
||||
) -> None: ...
|
||||
def get_limit_choices_to(self): ...
|
||||
def formfield(self, **kwargs: Any): ...
|
||||
def related_query_name(self): ...
|
||||
@property
|
||||
def target_field(self): ...
|
||||
def get_cache_name(self): ...
|
||||
|
||||
class ForeignObject:
|
||||
class ForeignObject(RelatedField):
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
requires_unique_target: bool = ...
|
||||
related_accessor_class: Any = ...
|
||||
forward_related_accessor_class: Any = ...
|
||||
rel_class: Any = ...
|
||||
from_fields: Any = ...
|
||||
to_fields: Any = ...
|
||||
swappable: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
to: Any,
|
||||
to: Union[Type[Model], str],
|
||||
on_delete: Callable,
|
||||
from_fields: Union[List[str], Tuple[str, str]],
|
||||
to_fields: Union[List[None], List[str], Tuple[str, str]],
|
||||
rel: Optional[ForeignObjectRel] = ...,
|
||||
related_name: Optional[str] = ...,
|
||||
from_fields: List[str],
|
||||
to_fields: Union[List[None], List[str]],
|
||||
rel: ManyToOneRel = ...,
|
||||
related_name: None = ...,
|
||||
related_query_name: None = ...,
|
||||
limit_choices_to: None = ...,
|
||||
parent_link: bool = ...,
|
||||
swappable: bool = ...,
|
||||
**kwargs,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def _check_to_fields_exist(self) -> List[Error]: ...
|
||||
def _check_unique_target(self) -> List[Error]: ...
|
||||
def check(self, **kwargs) -> List[Error]: ...
|
||||
def check(self, **kwargs: Any): ...
|
||||
def deconstruct(
|
||||
self
|
||||
) -> Tuple[
|
||||
None,
|
||||
str,
|
||||
List[Any],
|
||||
Dict[str, Union[str, bool, Callable, List[str], List[None]]],
|
||||
]: ...
|
||||
def resolve_related_fields(self) -> List[Tuple[ForeignKey, AutoField]]: ...
|
||||
@property
|
||||
def related_fields(self) -> List[Tuple[ForeignKey, AutoField]]: ...
|
||||
@property
|
||||
def reverse_related_fields(self): ...
|
||||
@property
|
||||
def local_related_fields(self): ...
|
||||
@property
|
||||
def foreign_related_fields(self) -> Tuple[AutoField]: ...
|
||||
def get_local_related_value(
|
||||
self, instance: Model
|
||||
) -> Tuple[Optional[int]]: ...
|
||||
def get_foreign_related_value(self, instance: Any): ...
|
||||
@staticmethod
|
||||
def get_instance_value_for_fields(
|
||||
instance: Model, fields: Tuple[ForeignKey]
|
||||
) -> Tuple[Optional[int]]: ...
|
||||
def get_attname_column(self): ...
|
||||
def get_joining_columns(self, reverse_join: bool = ...): ...
|
||||
def get_reverse_joining_columns(self) -> Tuple: ...
|
||||
def get_extra_descriptor_filter(
|
||||
self, instance: Model
|
||||
) -> Dict[Any, Any]: ...
|
||||
def get_extra_restriction(
|
||||
self, where_class: Type[WhereNode], alias: str, related_alias: str
|
||||
) -> None: ...
|
||||
def get_path_info(self, filtered_relation: Optional[Any] = ...): ...
|
||||
def get_reverse_path_info(self, filtered_relation: Optional[Any] = ...): ...
|
||||
@classmethod
|
||||
def get_lookups(
|
||||
cls
|
||||
) -> Dict[
|
||||
str,
|
||||
Type[
|
||||
Union[
|
||||
RelatedIn,
|
||||
RelatedExact,
|
||||
RelatedLessThan,
|
||||
RelatedGreaterThan,
|
||||
RelatedGreaterThanOrEqual,
|
||||
RelatedLessThanOrEqual,
|
||||
RelatedIsNull,
|
||||
]
|
||||
],
|
||||
]: ...
|
||||
def contribute_to_class(
|
||||
self,
|
||||
cls: Type[Model],
|
||||
name: str,
|
||||
private_only: bool = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def contribute_to_related_class(
|
||||
self, cls: Type[Model], related: ManyToOneRel
|
||||
) -> None: ...
|
||||
|
||||
class ForeignKey(ForeignObject):
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
rel_class: Any = ...
|
||||
empty_strings_allowed: bool = ...
|
||||
default_error_messages: Any = ...
|
||||
description: Any = ...
|
||||
db_constraint: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
to: Union[Type[Model], str],
|
||||
on_delete: Callable,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: None = ...,
|
||||
limit_choices_to: Optional[Callable] = ...,
|
||||
parent_link: bool = ...,
|
||||
to_field: Optional[str] = ...,
|
||||
db_constraint: bool = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any): ...
|
||||
def deconstruct(
|
||||
self
|
||||
) -> Tuple[None, str, List[Any], Dict[str, Union[str, bool, Callable]]]: ...
|
||||
def to_python(self, value: str) -> int: ...
|
||||
@property
|
||||
def target_field(self) -> AutoField: ...
|
||||
def get_reverse_path_info(self, filtered_relation: Optional[Any] = ...): ...
|
||||
def validate(self, value: Any, model_instance: Any): ...
|
||||
def get_attname(self) -> str: ...
|
||||
def get_attname_column(self) -> Tuple[str, str]: ...
|
||||
def get_default(self): ...
|
||||
def get_db_prep_save(self, value: Any, connection: Any): ...
|
||||
def get_db_prep_value(
|
||||
self, value: Any, connection: Any, prepared: bool = ...
|
||||
): ...
|
||||
def contribute_to_related_class(
|
||||
self, cls: Type[Model], related: ManyToOneRel
|
||||
) -> None: ...
|
||||
def formfield(self, *, using: Optional[Any] = ..., **kwargs: Any): ...
|
||||
def db_check(self, connection: DatabaseWrapper) -> List[Any]: ...
|
||||
def db_type(self, connection: DatabaseWrapper) -> str: ...
|
||||
def db_parameters(
|
||||
self, connection: DatabaseWrapper
|
||||
) -> Dict[str, Union[str, List[Any]]]: ...
|
||||
def convert_empty_strings(
|
||||
self, value: Any, expression: Any, connection: Any
|
||||
): ...
|
||||
def get_db_converters(self, connection: Any): ...
|
||||
def get_col(self, alias: Any, output_field: Optional[Any] = ...): ...
|
||||
|
||||
class OneToOneField(ForeignKey):
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
related_accessor_class: Any = ...
|
||||
forward_related_accessor_class: Any = ...
|
||||
rel_class: Any = ...
|
||||
description: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
to: Type[Model],
|
||||
on_delete: Callable,
|
||||
to_field: None = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def formfield(self, **kwargs: Any) -> None: ...
|
||||
def save_form_data(self, instance: Any, data: Any) -> None: ...
|
||||
|
||||
def create_many_to_many_intermediary_model(field: Any, klass: Any): ...
|
||||
|
||||
class ManyToManyField(RelatedField):
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
rel_class: Any = ...
|
||||
description: Any = ...
|
||||
has_null_arg: Any = ...
|
||||
db_table: Any = ...
|
||||
swappable: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
to: Type[Model],
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Optional[Callable] = ...,
|
||||
symmetrical: None = ...,
|
||||
through: None = ...,
|
||||
through_fields: None = ...,
|
||||
db_constraint: bool = ...,
|
||||
db_table: None = ...,
|
||||
swappable: bool = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any): ...
|
||||
def deconstruct(self): ...
|
||||
def get_path_info(self, filtered_relation: Optional[Any] = ...): ...
|
||||
def get_reverse_path_info(self, filtered_relation: Optional[Any] = ...): ...
|
||||
m2m_db_table: Any = ...
|
||||
def contribute_to_class(
|
||||
self, cls: Type[Model], name: str, **kwargs: Any
|
||||
) -> None: ...
|
||||
m2m_column_name: Any = ...
|
||||
m2m_reverse_name: Any = ...
|
||||
m2m_field_name: Any = ...
|
||||
m2m_reverse_field_name: Any = ...
|
||||
m2m_target_field_name: Any = ...
|
||||
m2m_reverse_target_field_name: Any = ...
|
||||
def contribute_to_related_class(
|
||||
self, cls: Type[Model], related: ManyToManyRel
|
||||
) -> None: ...
|
||||
def set_attributes_from_rel(self) -> None: ...
|
||||
def value_from_object(self, obj: Any): ...
|
||||
def save_form_data(self, instance: Any, data: Any) -> None: ...
|
||||
def formfield(self, *, using: Optional[Any] = ..., **kwargs: Any): ...
|
||||
def db_check(self, connection: Any): ...
|
||||
def db_type(self, connection: Any): ...
|
||||
def db_parameters(self, connection: Any): ...
|
||||
|
||||
Reference in New Issue
Block a user