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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
|
import datetime
from collections.abc import Iterable, Iterator, Mapping, Sequence
from typing import Any, Literal, Protocol, TypeAlias, type_check_only
import _typeshed
from django.core.files.base import File
from django.forms.renderers import BaseRenderer
from django.forms.utils import _DataT, _FilesT
from django.utils.choices import _Choices
from django.utils.datastructures import _ListOrTuple
from django.utils.safestring import SafeString
from typing_extensions import Self
_OptAttrs: TypeAlias = dict[str, Any]
class MediaOrderConflictWarning(RuntimeWarning): ...
class MediaAsset:
element_template: str
def __init__(self, path: str, **attributes: Any) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __html__(self) -> SafeString: ...
@property
def path(self) -> str: ...
class Script(MediaAsset):
element_template: str
def __init__(self, src: str, **attributes: Any) -> None: ...
class Media:
def __init__(
self,
media: type | None = None,
css: dict[str, Sequence[str]] | None = None,
js: Sequence[str] | None = None,
) -> None: ...
def render(self) -> SafeString: ...
def render_js(self) -> list[SafeString]: ...
def render_css(self) -> Iterable[SafeString]: ...
def absolute_path(self, path: str) -> str: ...
def __getitem__(self, name: str) -> Media: ...
@staticmethod
def merge(*lists: Iterable[Any]) -> list[Any]: ...
def __add__(self, other: Media) -> Media: ...
class MediaDefiningClass(type):
def __new__(
mcs: type[_typeshed.Self], # noqa: TID251
name: str,
bases: tuple[type, ...],
attrs: dict[str, Any],
) -> _typeshed.Self: ... # noqa: TID251
class Widget(metaclass=MediaDefiningClass):
needs_multipart_form: bool
is_localized: bool
is_required: bool
supports_microseconds: bool
attrs: _OptAttrs
template_name: str
def __init__(self, attrs: _OptAttrs | None = None) -> None: ...
def __deepcopy__(self, memo: dict[int, Any]) -> Self: ...
@property
def is_hidden(self) -> bool: ...
@property
def media(self) -> Media: ...
def subwidgets(self, name: str, value: Any, attrs: _OptAttrs | None = None) -> Iterator[dict[str, Any]]: ...
def format_value(self, value: Any) -> str | None: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
def render(
self, name: str, value: Any, attrs: _OptAttrs | None = None, renderer: BaseRenderer | None = None
) -> SafeString: ...
def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: _OptAttrs | None = None) -> dict[str, Any]: ...
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
def id_for_label(self, id_: str) -> str: ...
def use_required_attribute(self, initial: Any) -> bool: ...
class Input(Widget):
input_type: str
template_name: str
class TextInput(Input):
input_type: str
template_name: str
class NumberInput(Input):
input_type: str
template_name: str
class EmailInput(Input):
input_type: str
template_name: str
class URLInput(Input):
input_type: str
template_name: str
class ColorInput(Input):
input_type: str
template_name: str
class SearchInput(Input):
input_type: str
template_name: str
class TelInput(Input):
input_type: str
template_name: str
class PasswordInput(Input):
render_value: bool
input_type: str
template_name: str
def __init__(self, attrs: _OptAttrs | None = None, render_value: bool = False) -> None: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
class HiddenInput(Input):
choices: _Choices
input_type: str
template_name: str
class MultipleHiddenInput(HiddenInput):
template_name: str
class FileInput(Input):
allow_multiple_selected: bool
input_type: str
template_name: str
needs_multipart_form: bool
def format_value(self, value: Any) -> None: ...
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
def use_required_attribute(self, initial: Any) -> bool: ...
FILE_INPUT_CONTRADICTION: object
class ClearableFileInput(FileInput):
clear_checkbox_label: str
initial_text: str
input_text: str
template_name: str
checked: bool
def clear_checkbox_name(self, name: str) -> str: ...
def clear_checkbox_id(self, name: str) -> str: ...
def is_initial(self, value: File | str | None) -> bool: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
class Textarea(Widget):
template_name: str
def __init__(self, attrs: _OptAttrs | None = None) -> None: ...
class DateTimeBaseInput(TextInput):
format_key: str
format: str | None
supports_microseconds: bool
def __init__(self, attrs: _OptAttrs | None = None, format: str | None = None) -> None: ...
class DateInput(DateTimeBaseInput):
format_key: str
template_name: str
class DateTimeInput(DateTimeBaseInput):
format_key: str
template_name: str
class TimeInput(DateTimeBaseInput):
format_key: str
template_name: str
def boolean_check(v: Any) -> bool: ...
@type_check_only
class _CheckCallable(Protocol):
def __call__(self, value: Any, /) -> bool: ...
class CheckboxInput(Input):
check_test: _CheckCallable
input_type: str
template_name: str
def __init__(self, attrs: _OptAttrs | None = None, check_test: _CheckCallable | None = None) -> None: ...
class ChoiceWidget(Widget):
allow_multiple_selected: bool
input_type: str | None
template_name: str
option_template_name: str | None
add_id_index: bool
checked_attribute: Any
option_inherits_attrs: bool
choices: _Choices
def __init__(self, attrs: _OptAttrs | None = None, choices: _Choices = ()) -> None: ...
def subwidgets(self, name: str, value: Any, attrs: _OptAttrs | None = None) -> Iterator[dict[str, Any]]: ...
def options(self, name: str, value: list[str], attrs: _OptAttrs | None = None) -> Iterator[dict[str, Any]]: ...
def optgroups(
self, name: str, value: list[str], attrs: _OptAttrs | None = None
) -> list[tuple[str | None, list[dict[str, Any]], int | None]]: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
def create_option(
self,
name: str,
value: Any,
label: int | str,
selected: bool,
index: int,
subindex: int | None = None,
attrs: _OptAttrs | None = None,
) -> dict[str, Any]: ...
def id_for_label(self, id_: str, index: str = "0") -> str: ...
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ...
def format_value(self, value: Any) -> list[str]: ... # type: ignore[override]
class Select(ChoiceWidget):
input_type: str | None
template_name: str
option_template_name: str
add_id_index: bool
checked_attribute: Any
option_inherits_attrs: bool
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
def use_required_attribute(self, initial: Any) -> bool: ...
class NullBooleanSelect(Select):
def __init__(self, attrs: _OptAttrs | None = None) -> None: ...
def format_value(self, value: Any) -> str: ... # type: ignore[override]
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> bool | None: ...
class SelectMultiple(Select):
allow_multiple_selected: bool
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
class RadioSelect(ChoiceWidget):
can_add_related: bool
input_type: str
template_name: str
option_template_name: str
class CheckboxSelectMultiple(ChoiceWidget):
can_add_related: bool
input_type: str
template_name: str
option_template_name: str
def use_required_attribute(self, initial: Any) -> bool: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
def id_for_label(self, id_: str, index: str | None = None) -> str: ...
class MultiWidget(Widget):
template_name: str
widgets: Sequence[Widget]
def __init__(
self,
widgets: dict[str, Widget | type[Widget]] | Sequence[Widget | type[Widget]],
attrs: _OptAttrs | None = None,
) -> None: ...
@property
def is_hidden(self) -> bool: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
def id_for_label(self, id_: str) -> str: ...
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> list[Any]: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
def decompress(self, value: Any) -> Any | None: ...
@property
def needs_multipart_form(self) -> bool: ... # type: ignore[override]
class SplitDateTimeWidget(MultiWidget):
supports_microseconds: bool
template_name: str
widgets: tuple[DateInput, TimeInput]
def __init__(
self,
attrs: _OptAttrs | None = None,
date_format: str | None = None,
time_format: str | None = None,
date_attrs: dict[str, str] | None = None,
time_attrs: dict[str, str] | None = None,
) -> None: ...
def decompress(self, value: Any) -> tuple[datetime.date | None, datetime.time | None]: ...
class SplitHiddenDateTimeWidget(SplitDateTimeWidget):
template_name: str
def __init__(
self,
attrs: _OptAttrs | None = None,
date_format: str | None = None,
time_format: str | None = None,
date_attrs: dict[str, str] | None = None,
time_attrs: dict[str, str] | None = None,
) -> None: ...
class SelectDateWidget(Widget):
none_value: tuple[Literal[""], str]
month_field: str
day_field: str
year_field: str
template_name: str
input_type: str
select_widget: type[ChoiceWidget]
date_re: Any
years: Iterable[int | str]
months: Mapping[int, str]
year_none_value: tuple[Literal[""], str]
month_none_value: tuple[Literal[""], str]
day_none_value: tuple[Literal[""], str]
def __init__(
self,
attrs: _OptAttrs | None = None,
years: Iterable[int | str] | None = None,
months: Mapping[int, str] | None = None,
empty_label: str | _ListOrTuple[str] | None = None,
) -> None: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
def format_value(self, value: Any) -> dict[str, str | int | None]: ... # type: ignore[override]
def id_for_label(self, id_: str) -> str: ...
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> str | None | Any: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
__all__ = (
"CheckboxInput",
"CheckboxSelectMultiple",
"ClearableFileInput",
"ColorInput",
"DateInput",
"DateTimeInput",
"EmailInput",
"FileInput",
"HiddenInput",
"Media",
"MediaDefiningClass",
"MultiWidget",
"MultipleHiddenInput",
"NullBooleanSelect",
"NumberInput",
"PasswordInput",
"RadioSelect",
"Script",
"SearchInput",
"Select",
"SelectDateWidget",
"SelectMultiple",
"SplitDateTimeWidget",
"SplitHiddenDateTimeWidget",
"TelInput",
"TextInput",
"Textarea",
"TimeInput",
"URLInput",
"Widget",
)
|