File: formats.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 (47 lines) | stat: -rw-r--r-- 1,804 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
import types
from collections.abc import Iterator
from datetime import date, time
from datetime import datetime as builtin_datetime
from decimal import Decimal
from typing import Any, TypeVar, overload

ISO_INPUT_FORMATS: dict[str, list[str]]
FORMAT_SETTINGS: frozenset[str]

def reset_format_cache() -> None: ...
def iter_format_modules(lang: str, format_module_path: list[str] | str | None = None) -> Iterator[types.ModuleType]: ...
def get_format_modules(lang: str | None = None) -> list[types.ModuleType]: ...
def get_format(format_type: str, lang: str | None = None, use_l10n: bool | None = None) -> Any: ...

get_format_lazy: Any

def date_format(
    value: date | builtin_datetime | str, format: str | None = None, use_l10n: bool | None = None
) -> str: ...
def time_format(
    value: time | builtin_datetime | str, format: str | None = None, use_l10n: bool | None = None
) -> str: ...
def number_format(
    value: Decimal | float | str,
    decimal_pos: int | None = None,
    use_l10n: bool | None = None,
    force_grouping: bool = False,
) -> str: ...

_T = TypeVar("_T")

# Mypy considers this invalid (overlapping signatures), but thanks to implementation
# details it works as expected (all values from Union are `localize`d to str,
# while type of others is preserved)
@overload
def localize(value: builtin_datetime | date | time | Decimal | float | str, use_l10n: bool | None = None) -> str: ...
@overload
def localize(value: _T, use_l10n: bool | None = None) -> _T: ...
@overload
def localize_input(
    value: builtin_datetime | date | time | Decimal | float | str, default: str | None = None
) -> str: ...
@overload
def localize_input(value: _T, default: str | None = None) -> _T: ...
def sanitize_separators(value: _T) -> _T: ...
def sanitize_strftime_format(fmt: str) -> str: ...