File: composite.pyi

package info (click to toggle)
python-django-stubs 5.2.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,832 kB
  • sloc: python: 5,185; makefile: 15; sh: 8
file content (64 lines) | stat: -rw-r--r-- 2,628 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from collections.abc import Iterable, Iterator, Mapping
from typing import Any, Literal

from django.contrib.contenttypes.fields import GenericForeignKey
from django.core import validators  # due to weird mypy.stubtest error
from django.db.models import NOT_PROVIDED, Field
from django.db.models.base import Model
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.utils.choices import _ChoicesInput
from django.utils.functional import _StrOrPromise, cached_property

class AttributeSetter:
    def __init__(self, name: str, value: Any) -> None: ...

class CompositeAttribute:
    field: CompositePrimaryKey
    def __init__(self, field: CompositePrimaryKey) -> None: ...
    @property
    def attnames(self) -> list[str]: ...
    def __get__(self, instance: Model, cls: type[Model] | None = None) -> tuple[Any, ...]: ...
    def __set__(self, instance: Model, values: list[Any] | tuple[Any] | None) -> None: ...

class CompositePrimaryKey(Field):
    field_names: tuple[str]
    descriptor_class: type[CompositeAttribute]
    def __init__(
        self,
        *args: str,
        verbose_name: _StrOrPromise | None = None,
        name: str | None = None,
        primary_key: Literal[True] = True,
        max_length: int | None = None,
        unique: bool = False,
        blank: Literal[True] = True,
        null: bool = False,
        db_index: bool = False,
        rel: ForeignObjectRel | None = None,
        default: type[NOT_PROVIDED] = ...,
        editable: Literal[False] = False,
        serialize: bool = True,
        unique_for_date: str | None = None,
        unique_for_month: str | None = None,
        unique_for_year: str | None = None,
        choices: _ChoicesInput | None = None,
        help_text: _StrOrPromise = "",
        db_column: None = None,
        db_tablespace: str | None = None,
        auto_created: bool = False,
        validators: Iterable[validators._ValidatorCallable] = (),
        error_messages: Mapping[str, _StrOrPromise] | None = None,
        db_comment: str | None = None,
        db_default: type[NOT_PROVIDED] = ...,
    ) -> None: ...
    @cached_property
    def fields(
        self,
    ) -> tuple[Field | ForeignObjectRel | GenericForeignKey, ...]: ...
    @cached_property
    def columns(self) -> tuple[str, ...]: ...
    def __iter__(self) -> Iterator[Field | ForeignObjectRel | GenericForeignKey]: ...
    def __len__(self) -> int: ...
    def get_pk_value_on_save(self, instance: Model) -> tuple: ...  # actual type is tuple of field.value_from_object

def unnest(fields: Iterable[Field[Any, Any]]) -> list[Field[Any, Any]]: ...