mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 22:11:54 +08:00
initial commit
This commit is contained in:
70
django/forms/boundfield.pyi
Normal file
70
django/forms/boundfield.pyi
Normal file
@@ -0,0 +1,70 @@
|
||||
from django.forms.fields import Field
|
||||
from django.forms.forms import BaseForm
|
||||
from django.forms.renderers import DjangoTemplates
|
||||
from django.forms.utils import ErrorList
|
||||
from django.forms.widgets import (
|
||||
ChoiceWidget,
|
||||
HiddenInput,
|
||||
SplitHiddenDateTimeWidget,
|
||||
)
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class BoundField:
|
||||
def __getitem__(
|
||||
self,
|
||||
idx: Union[str, slice, int]
|
||||
) -> Union[BoundWidget, List[BoundWidget]]: ...
|
||||
def __init__(self, form: BaseForm, field: Field, name: str) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def as_hidden(self, attrs: None = ..., **kwargs) -> SafeText: ...
|
||||
def as_text(self, attrs: None = ..., **kwargs) -> SafeText: ...
|
||||
def as_textarea(self, attrs: None = ..., **kwargs) -> SafeText: ...
|
||||
def as_widget(
|
||||
self,
|
||||
widget: Optional[Union[HiddenInput, SplitHiddenDateTimeWidget]] = ...,
|
||||
attrs: None = ...,
|
||||
only_initial: bool = ...
|
||||
) -> SafeText: ...
|
||||
@property
|
||||
def auto_id(self) -> str: ...
|
||||
def build_widget_attrs(self, attrs: Dict[str, str], widget: Any = ...) -> Dict[str, Union[bool, str]]: ...
|
||||
def css_classes(self, extra_classes: None = ...) -> str: ...
|
||||
@property
|
||||
def data(self) -> Any: ...
|
||||
@property
|
||||
def errors(self) -> ErrorList: ...
|
||||
@cached_property
|
||||
def initial(self) -> Any: ...
|
||||
@property
|
||||
def is_hidden(self) -> bool: ...
|
||||
def label_tag(
|
||||
self,
|
||||
contents: Optional[SafeText] = ...,
|
||||
attrs: Optional[Dict[str, str]] = ...,
|
||||
label_suffix: Optional[str] = ...
|
||||
) -> SafeText: ...
|
||||
@cached_property
|
||||
def subwidgets(self) -> List[BoundWidget]: ...
|
||||
def value(self) -> Any: ...
|
||||
|
||||
|
||||
class BoundWidget:
|
||||
def __init__(
|
||||
self,
|
||||
parent_widget: ChoiceWidget,
|
||||
data: Dict[str, Any],
|
||||
renderer: DjangoTemplates
|
||||
) -> None: ...
|
||||
@property
|
||||
def choice_label(self) -> str: ...
|
||||
def tag(self, wrap_label: bool = ...) -> SafeText: ...
|
||||
@property
|
||||
def template_name(self) -> str: ...
|
||||
255
django/forms/fields.pyi
Normal file
255
django/forms/fields.pyi
Normal file
@@ -0,0 +1,255 @@
|
||||
from datetime import (
|
||||
date,
|
||||
datetime,
|
||||
time,
|
||||
timedelta,
|
||||
)
|
||||
from decimal import Decimal
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.db.models.fields.files import FieldFile
|
||||
from django.forms.boundfield import BoundField
|
||||
from django.forms.forms import BaseForm
|
||||
from django.forms.widgets import (
|
||||
ClearableFileInput,
|
||||
Input,
|
||||
Widget,
|
||||
)
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class BaseTemporalField:
|
||||
def __init__(self, *, input_formats = ..., **kwargs) -> None: ...
|
||||
def to_python(self, value: str) -> Union[date, time]: ...
|
||||
|
||||
|
||||
class BooleanField:
|
||||
def has_changed(self, initial: Optional[bool], data: Optional[Union[bool, str]]) -> bool: ...
|
||||
def to_python(self, value: Optional[Union[str, int]]) -> bool: ...
|
||||
def validate(self, value: bool) -> None: ...
|
||||
|
||||
|
||||
class CallableChoiceIterator:
|
||||
def __init__(self, choices_func: Callable) -> None: ...
|
||||
def __iter__(self) -> None: ...
|
||||
|
||||
|
||||
class CharField:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
max_length = ...,
|
||||
min_length = ...,
|
||||
strip = ...,
|
||||
empty_value = ...,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
def to_python(self, value: Optional[Union[int, Tuple, str]]) -> Optional[str]: ...
|
||||
def widget_attrs(self, widget: Widget) -> Dict[str, str]: ...
|
||||
|
||||
|
||||
class ChoiceField:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> ChoiceField: ...
|
||||
def __init__(self, *, choices = ..., **kwargs) -> None: ...
|
||||
def _get_choices(self) -> Any: ...
|
||||
def _set_choices(self, value: Any) -> None: ...
|
||||
def to_python(self, value: Optional[str]) -> str: ...
|
||||
def valid_value(self, value: str) -> bool: ...
|
||||
def validate(self, value: str) -> None: ...
|
||||
|
||||
|
||||
class ComboField:
|
||||
def __init__(self, fields: List[CharField], **kwargs) -> None: ...
|
||||
def clean(self, value: Optional[str]) -> str: ...
|
||||
|
||||
|
||||
class DateField:
|
||||
def strptime(self, value: str, format: str) -> date: ...
|
||||
def to_python(self, value: Optional[Union[date, str]]) -> Optional[date]: ...
|
||||
|
||||
|
||||
class DateTimeField:
|
||||
def prepare_value(self, value: Optional[datetime]) -> Optional[datetime]: ...
|
||||
def strptime(self, value: str, format: str) -> datetime: ...
|
||||
def to_python(self, value: Optional[Union[str, date]]) -> Optional[datetime]: ...
|
||||
|
||||
|
||||
class DecimalField:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
max_value = ...,
|
||||
min_value = ...,
|
||||
max_digits = ...,
|
||||
decimal_places = ...,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
def to_python(self, value: Optional[Union[str, float]]) -> Optional[Decimal]: ...
|
||||
def validate(self, value: Decimal) -> None: ...
|
||||
def widget_attrs(self, widget: Widget) -> Dict[str, str]: ...
|
||||
|
||||
|
||||
class DurationField:
|
||||
def prepare_value(self, value: Optional[timedelta]) -> Optional[str]: ...
|
||||
def to_python(self, value: Union[str, int]) -> timedelta: ...
|
||||
|
||||
|
||||
class EmailField:
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
|
||||
|
||||
class Field:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> Field: ...
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
required = ...,
|
||||
widget = ...,
|
||||
label = ...,
|
||||
initial = ...,
|
||||
help_text = ...,
|
||||
error_messages = ...,
|
||||
show_hidden_initial = ...,
|
||||
validators = ...,
|
||||
localize = ...,
|
||||
disabled = ...,
|
||||
label_suffix = ...
|
||||
) -> None: ...
|
||||
def bound_data(self, data: Any, initial: Any) -> Any: ...
|
||||
def clean(self, value: Any) -> Any: ...
|
||||
def get_bound_field(self, form: BaseForm, field_name: str) -> BoundField: ...
|
||||
def has_changed(self, initial: Any, data: Optional[str]) -> bool: ...
|
||||
def prepare_value(self, value: Any) -> Any: ...
|
||||
def run_validators(self, value: Any) -> None: ...
|
||||
def to_python(self, value: Any) -> Any: ...
|
||||
def validate(self, value: Any) -> None: ...
|
||||
def widget_attrs(self, widget: Widget) -> Dict[Any, Any]: ...
|
||||
|
||||
|
||||
class FileField:
|
||||
def __init__(self, *, max_length = ..., allow_empty_file = ..., **kwargs) -> None: ...
|
||||
def bound_data(
|
||||
self,
|
||||
data: Union[str, SimpleUploadedFile],
|
||||
initial: None
|
||||
) -> Union[str, SimpleUploadedFile]: ...
|
||||
def clean(
|
||||
self,
|
||||
data: Optional[Union[str, bool, SimpleUploadedFile]],
|
||||
initial: Optional[Union[str, FieldFile]] = ...
|
||||
) -> Any: ...
|
||||
def has_changed(self, initial: Union[str, FieldFile], data: Optional[str]) -> bool: ...
|
||||
def to_python(
|
||||
self,
|
||||
data: Optional[Union[str, SimpleUploadedFile]]
|
||||
) -> Optional[SimpleUploadedFile]: ...
|
||||
|
||||
|
||||
class FilePathField:
|
||||
def __init__(
|
||||
self,
|
||||
path: str,
|
||||
*,
|
||||
match = ...,
|
||||
recursive = ...,
|
||||
allow_files = ...,
|
||||
allow_folders = ...,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class FloatField:
|
||||
def to_python(self, value: str) -> Optional[float]: ...
|
||||
def validate(self, value: Optional[float]) -> None: ...
|
||||
def widget_attrs(self, widget: Input) -> Dict[str, Union[int, str]]: ...
|
||||
|
||||
|
||||
class GenericIPAddressField:
|
||||
def __init__(self, *, protocol = ..., unpack_ipv4 = ..., **kwargs) -> None: ...
|
||||
def to_python(self, value: str) -> str: ...
|
||||
|
||||
|
||||
class ImageField:
|
||||
def widget_attrs(self, widget: ClearableFileInput) -> Dict[str, str]: ...
|
||||
|
||||
|
||||
class IntegerField:
|
||||
def __init__(self, *, max_value = ..., min_value = ..., **kwargs) -> None: ...
|
||||
def to_python(self, value: Optional[Union[float, int, str]]) -> Optional[int]: ...
|
||||
def widget_attrs(self, widget: Input) -> Dict[str, Union[Decimal, int]]: ...
|
||||
|
||||
|
||||
class MultiValueField:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> MultiValueField: ...
|
||||
def __init__(
|
||||
self,
|
||||
fields: Union[Tuple[DateField, TimeField], Tuple[CharField, MultipleChoiceField, SplitDateTimeField], Tuple[CharField, CharField]],
|
||||
*,
|
||||
require_all_fields = ...,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
def clean(
|
||||
self,
|
||||
value: Union[str, List[Union[str, List[str]]], List[str]]
|
||||
) -> Optional[Union[str, datetime]]: ...
|
||||
def has_changed(
|
||||
self,
|
||||
initial: Optional[Union[datetime, List[None], List[str]]],
|
||||
data: Union[List[None], List[str]]
|
||||
) -> bool: ...
|
||||
def validate(self, value: Union[str, datetime]) -> None: ...
|
||||
|
||||
|
||||
class MultipleChoiceField:
|
||||
def has_changed(self, initial: Optional[Union[str, List[int]]], data: Union[str, List[str]]) -> bool: ...
|
||||
def to_python(self, value: Optional[Union[Tuple, str, List[str]]]) -> List[str]: ...
|
||||
def validate(self, value: List[str]) -> None: ...
|
||||
|
||||
|
||||
class NullBooleanField:
|
||||
def to_python(self, value: Optional[Union[str, bool]]) -> Optional[bool]: ...
|
||||
def validate(self, value: Optional[bool]) -> None: ...
|
||||
|
||||
|
||||
class RegexField:
|
||||
def __init__(self, regex: str, **kwargs) -> None: ...
|
||||
def _set_regex(self, regex: str) -> None: ...
|
||||
|
||||
|
||||
class SlugField:
|
||||
def __init__(self, *, allow_unicode = ..., **kwargs) -> None: ...
|
||||
|
||||
|
||||
class SplitDateTimeField:
|
||||
def __init__(self, *, input_date_formats = ..., input_time_formats = ..., **kwargs) -> None: ...
|
||||
def compress(self, data_list: List[Union[date, time]]) -> Optional[datetime]: ...
|
||||
|
||||
|
||||
class TimeField:
|
||||
def strptime(self, value: str, format: str) -> time: ...
|
||||
def to_python(self, value: Optional[Union[str, time]]) -> Optional[time]: ...
|
||||
|
||||
|
||||
class TypedChoiceField:
|
||||
def __init__(self, *, coerce = ..., empty_value = ..., **kwargs) -> None: ...
|
||||
def _coerce(self, value: Optional[Union[str, int]]) -> Optional[Union[int, str]]: ...
|
||||
def clean(self, value: Optional[str]) -> Optional[Union[str, int]]: ...
|
||||
|
||||
|
||||
class TypedMultipleChoiceField:
|
||||
def __init__(self, *, coerce = ..., **kwargs) -> None: ...
|
||||
def _coerce(self, value: List[str]) -> Optional[Union[List[Decimal], List[int]]]: ...
|
||||
def clean(self, value: List[str]) -> Optional[Union[List[bool], List[int]]]: ...
|
||||
def validate(self, value: List[str]) -> None: ...
|
||||
|
||||
|
||||
class URLField:
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
def to_python(self, value: Optional[Union[str, int]]) -> Optional[str]: ...
|
||||
61
django/forms/forms.pyi
Normal file
61
django/forms/forms.pyi
Normal file
@@ -0,0 +1,61 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.forms.boundfield import BoundField
|
||||
from django.forms.utils import (
|
||||
ErrorDict,
|
||||
ErrorList,
|
||||
)
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class BaseForm:
|
||||
def __getitem__(self, name: str) -> BoundField: ...
|
||||
def __init__(
|
||||
self,
|
||||
data: Any = ...,
|
||||
files: Optional[Union[Dict[str, SimpleUploadedFile], MultiValueDict]] = ...,
|
||||
auto_id: Optional[Union[str, bool]] = ...,
|
||||
prefix: Optional[str] = ...,
|
||||
initial: Any = ...,
|
||||
error_class: Type[ErrorList] = ...,
|
||||
label_suffix: None = ...,
|
||||
empty_permitted: bool = ...,
|
||||
field_order: None = ...,
|
||||
use_required_attribute: Optional[bool] = ...,
|
||||
renderer: object = ...
|
||||
) -> None: ...
|
||||
def __iter__(self) -> Iterator[BoundField]: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def _clean_fields(self) -> None: ...
|
||||
def _clean_form(self) -> None: ...
|
||||
def _html_output(
|
||||
self,
|
||||
normal_row: str,
|
||||
error_row: str,
|
||||
row_ender: str,
|
||||
help_text_html: str,
|
||||
errors_on_separate_row: bool
|
||||
) -> SafeText: ...
|
||||
def _post_clean(self) -> None: ...
|
||||
def add_error(self, field: Optional[str], error: Union[str, ValidationError]) -> None: ...
|
||||
def add_initial_prefix(self, field_name: str) -> str: ...
|
||||
def add_prefix(self, field_name: str) -> str: ...
|
||||
def as_p(self) -> SafeText: ...
|
||||
def as_table(self) -> SafeText: ...
|
||||
def as_ul(self) -> SafeText: ...
|
||||
@cached_property
|
||||
def changed_data(self) -> List[str]: ...
|
||||
def clean(self) -> Dict[str, Any]: ...
|
||||
@property
|
||||
def errors(self) -> ErrorDict: ...
|
||||
def full_clean(self) -> None: ...
|
||||
11
django/forms/formsets.pyi
Normal file
11
django/forms/formsets.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import (
|
||||
Any,
|
||||
List,
|
||||
)
|
||||
|
||||
|
||||
def all_valid(formsets: List[Any]) -> bool: ...
|
||||
|
||||
|
||||
class ManagementForm:
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
132
django/forms/models.pyi
Normal file
132
django/forms/models.pyi
Normal file
@@ -0,0 +1,132 @@
|
||||
from collections import OrderedDict
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
from django.db.models.manager import Manager
|
||||
from django.db.models.query import QuerySet
|
||||
from django.forms.fields import Field
|
||||
from django.forms.utils import ErrorList
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
def _get_foreign_key(
|
||||
parent_model: Any,
|
||||
model: Any,
|
||||
fk_name: Optional[str] = ...,
|
||||
can_fail: bool = ...
|
||||
) -> ForeignKey: ...
|
||||
|
||||
|
||||
def apply_limit_choices_to_to_formfield(formfield: Field) -> None: ...
|
||||
|
||||
|
||||
class BaseModelForm:
|
||||
def __init__(
|
||||
self,
|
||||
data: Any = ...,
|
||||
files: Optional[Dict[str, SimpleUploadedFile]] = ...,
|
||||
auto_id: Union[str, bool] = ...,
|
||||
prefix: None = ...,
|
||||
initial: Optional[Dict[str, Union[Model, List[Model], QuerySet]]] = ...,
|
||||
error_class: Type[ErrorList] = ...,
|
||||
label_suffix: None = ...,
|
||||
empty_permitted: bool = ...,
|
||||
instance: Any = ...,
|
||||
use_required_attribute: None = ...,
|
||||
renderer: None = ...
|
||||
) -> None: ...
|
||||
def _get_validation_exclusions(self) -> List[str]: ...
|
||||
def _post_clean(self) -> None: ...
|
||||
def _save_m2m(self) -> None: ...
|
||||
def _update_errors(self, errors: ValidationError) -> None: ...
|
||||
def clean(self) -> Dict[str, Any]: ...
|
||||
def save(self, commit: bool = ...) -> Model: ...
|
||||
def validate_unique(self) -> None: ...
|
||||
|
||||
|
||||
class InlineForeignKeyField:
|
||||
def __init__(
|
||||
self,
|
||||
parent_instance: Model,
|
||||
*args,
|
||||
pk_field = ...,
|
||||
to_field = ...,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
def clean(self, value: Optional[Union[str, int]]) -> Model: ...
|
||||
def has_changed(self, initial: Optional[Union[str, int]], data: Optional[Union[str, int]]) -> bool: ...
|
||||
|
||||
|
||||
class ModelChoiceField:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> ModelChoiceField: ...
|
||||
def __init__(
|
||||
self,
|
||||
queryset: QuerySet,
|
||||
*,
|
||||
empty_label = ...,
|
||||
required = ...,
|
||||
widget = ...,
|
||||
label = ...,
|
||||
initial = ...,
|
||||
help_text = ...,
|
||||
to_field_name = ...,
|
||||
limit_choices_to = ...,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
def _get_choices(self) -> ModelChoiceIterator: ...
|
||||
def _get_queryset(self) -> QuerySet: ...
|
||||
def _set_queryset(self, queryset: Union[QuerySet, Manager]) -> None: ...
|
||||
def get_limit_choices_to(self) -> Any: ...
|
||||
def has_changed(self, initial: Optional[Union[int, UUID]], data: Optional[Union[str, int]]) -> bool: ...
|
||||
def label_from_instance(self, obj: Model) -> str: ...
|
||||
def prepare_value(self, value: Any) -> Optional[Union[UUID, str, int]]: ...
|
||||
def to_python(self, value: Optional[Union[str, List[List[str]], int]]) -> Any: ...
|
||||
def validate(self, value: Any) -> None: ...
|
||||
|
||||
|
||||
class ModelChoiceIterator:
|
||||
def __bool__(self) -> bool: ...
|
||||
def __init__(self, field: ModelChoiceField) -> None: ...
|
||||
def __iter__(self) -> Iterator[Union[Tuple[int, str], Tuple[str, str]]]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def choice(self, obj: Model) -> Tuple[int, str]: ...
|
||||
|
||||
|
||||
class ModelFormMetaclass:
|
||||
@staticmethod
|
||||
def __new__(
|
||||
mcs: Type[ModelFormMetaclass],
|
||||
name: str,
|
||||
bases: Tuple[Type[ModelForm]],
|
||||
attrs: OrderedDict
|
||||
) -> Any: ...
|
||||
|
||||
|
||||
class ModelFormOptions:
|
||||
def __init__(self, options: Any = ...) -> None: ...
|
||||
|
||||
|
||||
class ModelMultipleChoiceField:
|
||||
def __init__(self, queryset: QuerySet, **kwargs) -> None: ...
|
||||
def _check_values(
|
||||
self,
|
||||
value: Union[List[int], Tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int], List[str]]
|
||||
) -> QuerySet: ...
|
||||
def clean(self, value: Union[List[List[str]], str, List[int], List[str]]) -> QuerySet: ...
|
||||
def has_changed(self, initial: List[Model], data: List[str]) -> bool: ...
|
||||
def prepare_value(self, value: Any) -> Any: ...
|
||||
def to_python(
|
||||
self,
|
||||
value: Tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int]
|
||||
) -> List[Model]: ...
|
||||
21
django/forms/renderers.pyi
Normal file
21
django/forms/renderers.pyi
Normal file
@@ -0,0 +1,21 @@
|
||||
from django.template.backends.django import (
|
||||
DjangoTemplates,
|
||||
Template,
|
||||
)
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
)
|
||||
|
||||
|
||||
def get_default_renderer() -> DjangoTemplates: ...
|
||||
|
||||
|
||||
class BaseRenderer:
|
||||
def render(self, template_name: str, context: Dict[str, Any], request: None = ...) -> str: ...
|
||||
|
||||
|
||||
class EngineMixin:
|
||||
@cached_property
|
||||
def engine(self) -> DjangoTemplates: ...
|
||||
def get_template(self, template_name: str) -> Template: ...
|
||||
52
django/forms/utils.pyi
Normal file
52
django/forms/utils.pyi
Normal file
@@ -0,0 +1,52 @@
|
||||
from datetime import datetime
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def flatatt(attrs: Dict[str, Union[str, None]]) -> SafeText: ...
|
||||
|
||||
|
||||
def from_current_timezone(value: datetime) -> datetime: ...
|
||||
|
||||
|
||||
def pretty_name(name: str) -> str: ...
|
||||
|
||||
|
||||
def to_current_timezone(value: datetime) -> datetime: ...
|
||||
|
||||
|
||||
class ErrorDict:
|
||||
def as_data(self) -> Dict[str, List[ValidationError]]: ...
|
||||
def as_json(self, escape_html: bool = ...) -> str: ...
|
||||
def as_ul(self) -> SafeText: ...
|
||||
def get_json_data(self, escape_html: bool = ...) -> Dict[str, List[Dict[str, str]]]: ...
|
||||
|
||||
|
||||
class ErrorList:
|
||||
def __contains__(self, item: str) -> bool: ...
|
||||
def __eq__(self, other: Union[List[str], ErrorList]) -> bool: ...
|
||||
def __getitem__(self, i: Union[str, int]) -> str: ...
|
||||
def __init__(
|
||||
self,
|
||||
initlist: Optional[Union[List[ValidationError], ErrorList, List[str]]] = ...,
|
||||
error_class: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def __reduce_ex__(
|
||||
self,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> Tuple[Callable, Tuple[Type[ErrorList]], Dict[str, Union[List[ValidationError], str]], None, None]: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def as_data(self) -> List[ValidationError]: ...
|
||||
def as_text(self) -> str: ...
|
||||
def as_ul(self) -> str: ...
|
||||
def get_json_data(self, escape_html: bool = ...) -> List[Dict[str, str]]: ...
|
||||
312
django/forms/widgets.pyi
Normal file
312
django/forms/widgets.pyi
Normal file
@@ -0,0 +1,312 @@
|
||||
from datetime import (
|
||||
date,
|
||||
datetime,
|
||||
time,
|
||||
)
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.db.models.fields.files import FieldFile
|
||||
from django.forms.renderers import DjangoTemplates
|
||||
from django.http.request import QueryDict
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.utils.safestring import SafeText
|
||||
from itertools import chain
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class CheckboxInput:
|
||||
def __init__(self, attrs: Optional[Dict[str, str]] = ..., check_test: Optional[Callable] = ...) -> None: ...
|
||||
def format_value(self, value: Optional[Union[str, int]]) -> Optional[str]: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Optional[Union[str, int]],
|
||||
attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]]
|
||||
) -> Dict[str, Any]: ...
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: Any,
|
||||
files: Union[Dict[str, SimpleUploadedFile], MultiValueDict],
|
||||
name: str
|
||||
) -> bool: ...
|
||||
def value_omitted_from_data(
|
||||
self,
|
||||
data: Union[Dict[str, str], Dict[str, Union[str, List[int]]], Dict[str, Union[int, str, None, datetime]], QueryDict],
|
||||
files: MultiValueDict,
|
||||
name: str
|
||||
) -> bool: ...
|
||||
|
||||
|
||||
class CheckboxSelectMultiple:
|
||||
def id_for_label(self, id_: str, index: Optional[str] = ...) -> str: ...
|
||||
def use_required_attribute(self, initial: None) -> bool: ...
|
||||
def value_omitted_from_data(self, data: Dict[Any, Any], files: Dict[Any, Any], name: str) -> bool: ...
|
||||
|
||||
|
||||
class ChoiceWidget:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> ChoiceWidget: ...
|
||||
def __init__(
|
||||
self,
|
||||
attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, str]]] = ...,
|
||||
choices: Any = ...
|
||||
) -> None: ...
|
||||
def create_option(
|
||||
self,
|
||||
name: str,
|
||||
value: Union[str, time, int],
|
||||
label: Union[str, int],
|
||||
selected: Union[bool, Set[str]],
|
||||
index: int,
|
||||
subindex: Optional[int] = ...,
|
||||
attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] = ...
|
||||
) -> Dict[str, Any]: ...
|
||||
def format_value(self, value: Any) -> List[str]: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Any,
|
||||
attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]]
|
||||
) -> Dict[str, Any]: ...
|
||||
def id_for_label(self, id_: str, index: str = ...) -> str: ...
|
||||
def optgroups(
|
||||
self,
|
||||
name: str,
|
||||
value: List[str],
|
||||
attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] = ...
|
||||
) -> Any: ...
|
||||
def options(self, name: str, value: List[str], attrs: Dict[str, Union[bool, str]] = ...) -> None: ...
|
||||
def subwidgets(self, name: str, value: Optional[List[str]], attrs: Dict[str, Union[bool, str]] = ...) -> None: ...
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: Any,
|
||||
files: MultiValueDict,
|
||||
name: str
|
||||
) -> Optional[Union[str, int, List[str]]]: ...
|
||||
|
||||
|
||||
class ClearableFileInput:
|
||||
def clear_checkbox_id(self, name: str) -> str: ...
|
||||
def clear_checkbox_name(self, name: str) -> str: ...
|
||||
def format_value(
|
||||
self,
|
||||
value: Optional[Union[str, FieldFile]]
|
||||
) -> Optional[FieldFile]: ...
|
||||
def is_initial(self, value: Any) -> bool: ...
|
||||
def use_required_attribute(self, initial: Optional[FieldFile]) -> bool: ...
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: Union[Dict[str, bool], Dict[str, str], Dict[str, None], QueryDict],
|
||||
files: Dict[str, Union[str, SimpleUploadedFile]],
|
||||
name: str
|
||||
) -> Optional[Union[str, SimpleUploadedFile]]: ...
|
||||
def value_omitted_from_data(self, data: Dict[str, str], files: Dict[Any, Any], name: str) -> bool: ...
|
||||
|
||||
|
||||
class DateTimeBaseInput:
|
||||
def __init__(self, attrs: Optional[Dict[str, str]] = ..., format: Optional[str] = ...) -> None: ...
|
||||
def format_value(self, value: Optional[Union[time, str, date]]) -> Optional[str]: ...
|
||||
|
||||
|
||||
class FileInput:
|
||||
def format_value(self, value: None) -> None: ...
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: Union[Dict[str, bool], Dict[str, str], QueryDict],
|
||||
files: Dict[str, SimpleUploadedFile],
|
||||
name: str
|
||||
) -> Optional[SimpleUploadedFile]: ...
|
||||
def value_omitted_from_data(
|
||||
self,
|
||||
data: Dict[Any, Any],
|
||||
files: Dict[str, Union[str, SimpleUploadedFile]],
|
||||
name: str
|
||||
) -> bool: ...
|
||||
|
||||
|
||||
class Input:
|
||||
def __init__(self, attrs: Optional[Union[Dict[str, str], Dict[str, bool], Dict[str, int]]] = ...) -> None: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Any,
|
||||
attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]]
|
||||
) -> Dict[str, Any]: ...
|
||||
|
||||
|
||||
class Media:
|
||||
def __add__(self, other: Media) -> Media: ...
|
||||
def __getitem__(self, name: str) -> Media: ...
|
||||
def __init__(
|
||||
self,
|
||||
media: Optional[Type[object]] = ...,
|
||||
css: Optional[Union[Dict[str, Tuple[str, str]], Dict[str, Tuple[str]], Dict[str, List[str]]]] = ...,
|
||||
js: Any = ...
|
||||
) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def absolute_path(self, path: str) -> str: ...
|
||||
@staticmethod
|
||||
def merge(list_1: Union[List[str], Tuple[str], List[int]], list_2: Any) -> Union[List[int], List[str]]: ...
|
||||
def render(self) -> SafeText: ...
|
||||
def render_css(self) -> chain: ...
|
||||
def render_js(self) -> List[SafeText]: ...
|
||||
|
||||
|
||||
class MediaDefiningClass:
|
||||
@staticmethod
|
||||
def __new__(mcs: Type[MediaDefiningClass], name: str, bases: Tuple, attrs: Any) -> Any: ...
|
||||
|
||||
|
||||
class MultiWidget:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> MultiWidget: ...
|
||||
def __init__(self, widgets: Any, attrs: Optional[Dict[str, str]] = ...) -> None: ...
|
||||
def _get_media(self) -> Media: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Optional[Union[str, datetime, List[str]]],
|
||||
attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, str]]]
|
||||
) -> Dict[str, Any]: ...
|
||||
def id_for_label(self, id_: str) -> str: ...
|
||||
@property
|
||||
def is_hidden(self) -> bool: ...
|
||||
@property
|
||||
def needs_multipart_form(self) -> bool: ...
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: Union[Dict[str, str], Dict[str, Union[str, List[str]]], QueryDict],
|
||||
files: MultiValueDict,
|
||||
name: str
|
||||
) -> Union[List[None], List[str]]: ...
|
||||
def value_omitted_from_data(
|
||||
self,
|
||||
data: Union[Dict[str, str], QueryDict],
|
||||
files: MultiValueDict,
|
||||
name: str
|
||||
) -> bool: ...
|
||||
|
||||
|
||||
class MultipleHiddenInput:
|
||||
def format_value(self, value: Union[List[int], List[str]]) -> Union[List[int], List[str]]: ...
|
||||
def get_context(self, name: str, value: List[str], attrs: Optional[Dict[str, str]]) -> Dict[str, Dict[str, Any]]: ...
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: MultiValueDict,
|
||||
files: Dict[Any, Any],
|
||||
name: str
|
||||
) -> List[str]: ...
|
||||
|
||||
|
||||
class NullBooleanSelect:
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
def format_value(self, value: Optional[str]) -> str: ...
|
||||
def value_from_datadict(self, data: Dict[str, Union[bool, str]], files: Dict[Any, Any], name: str) -> Optional[bool]: ...
|
||||
|
||||
|
||||
class PasswordInput:
|
||||
def __init__(self, attrs: Optional[Dict[str, bool]] = ..., render_value: bool = ...) -> None: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Optional[str],
|
||||
attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool]]]
|
||||
) -> Dict[str, Dict[str, Any]]: ...
|
||||
|
||||
|
||||
class Select:
|
||||
@staticmethod
|
||||
def _choice_has_empty_value(choice: Union[Tuple[None, str], Tuple[str, str]]) -> bool: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Any,
|
||||
attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]]
|
||||
) -> Dict[str, Any]: ...
|
||||
def use_required_attribute(self, initial: Any) -> bool: ...
|
||||
|
||||
|
||||
class SelectDateWidget:
|
||||
def __init__(
|
||||
self,
|
||||
attrs: None = ...,
|
||||
years: Optional[Union[range, Tuple[str]]] = ...,
|
||||
months: None = ...,
|
||||
empty_label: Optional[Tuple[str, str, str]] = ...
|
||||
) -> None: ...
|
||||
@staticmethod
|
||||
def _parse_date_fmt() -> Iterator[str]: ...
|
||||
def format_value(self, value: Optional[Union[str, date]]) -> Dict[str, Union[None, int, str]]: ...
|
||||
def value_from_datadict(self, data: Dict[str, str], files: Dict[Any, Any], name: str) -> Optional[str]: ...
|
||||
def value_omitted_from_data(self, data: Dict[str, str], files: Dict[Any, Any], name: str) -> bool: ...
|
||||
|
||||
|
||||
class SelectMultiple:
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: Any,
|
||||
files: MultiValueDict,
|
||||
name: str
|
||||
) -> Optional[Union[str, List[int], List[str]]]: ...
|
||||
def value_omitted_from_data(self, data: Dict[Any, Any], files: Dict[Any, Any], name: str) -> bool: ...
|
||||
|
||||
|
||||
class SplitDateTimeWidget:
|
||||
def __init__(
|
||||
self,
|
||||
attrs: Optional[Dict[str, str]] = ...,
|
||||
date_format: None = ...,
|
||||
time_format: None = ...,
|
||||
date_attrs: Optional[Dict[str, str]] = ...,
|
||||
time_attrs: Optional[Dict[str, str]] = ...
|
||||
) -> None: ...
|
||||
def decompress(
|
||||
self,
|
||||
value: Optional[datetime]
|
||||
) -> Union[List[None], List[Union[date, time]]]: ...
|
||||
|
||||
|
||||
class SplitHiddenDateTimeWidget:
|
||||
def __init__(
|
||||
self,
|
||||
attrs: None = ...,
|
||||
date_format: None = ...,
|
||||
time_format: None = ...,
|
||||
date_attrs: None = ...,
|
||||
time_attrs: None = ...
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class Textarea:
|
||||
def __init__(self, attrs: Optional[Union[Dict[str, str], Dict[str, int]]] = ...) -> None: ...
|
||||
|
||||
|
||||
class Widget:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> Widget: ...
|
||||
def __init__(self, attrs: Any = ...) -> None: ...
|
||||
def _render(
|
||||
self,
|
||||
template_name: str,
|
||||
context: Dict[str, Any],
|
||||
renderer: Optional[DjangoTemplates] = ...
|
||||
) -> SafeText: ...
|
||||
def build_attrs(
|
||||
self,
|
||||
base_attrs: Dict[str, Union[str, int, float]],
|
||||
extra_attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] = ...
|
||||
) -> Dict[str, Union[str, int, float]]: ...
|
||||
def format_value(self, value: Any) -> Optional[str]: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Any,
|
||||
attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]]
|
||||
) -> Dict[str, Any]: ...
|
||||
Reference in New Issue
Block a user