first version finished

This commit is contained in:
Maxim Kurnikov
2018-07-29 18:27:46 +03:00
parent a9f215bf64
commit c180555415
59 changed files with 2118 additions and 0 deletions

4
django/utils/_os.pyi Normal file
View File

@@ -0,0 +1,4 @@
def safe_join(base: str, *paths) -> str: ...
def symlinks_supported(): ...

38
django/utils/archive.pyi Normal file
View File

@@ -0,0 +1,38 @@
from typing import (
List,
Tuple,
Type,
Union,
)
def extract(path: str, to_path: str = ...) -> None: ...
class Archive:
def __enter__(self) -> Archive: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def __init__(self, file: str) -> None: ...
@staticmethod
def _archive_cls(file: str) -> Type[BaseArchive]: ...
def close(self) -> None: ...
def extract(self, to_path: str = ...) -> None: ...
class BaseArchive:
@staticmethod
def _copy_permissions(mode: int, filename: str) -> None: ...
def has_leading_dir(self, paths: List[str]) -> bool: ...
def split_leading_dir(self, path: str) -> Union[List[str], Tuple[str, str]]: ...
class TarArchive:
def __init__(self, file: str) -> None: ...
def close(self) -> None: ...
def extract(self, to_path: str) -> None: ...
class ZipArchive:
def __init__(self, file: str) -> None: ...
def close(self) -> None: ...
def extract(self, to_path: str) -> None: ...

View File

@@ -0,0 +1,18 @@
from typing import (
Callable,
List,
Optional,
Union,
)
def check_errors(fn: Callable) -> Callable: ...
def clean_files(filelist: Union[List[Union[None, bool]], List[str], List[Union[None, str]]]) -> List[str]: ...
def gen_filenames(only_new: bool = ...) -> List[str]: ...
def reset_translations() -> None: ...

10
django/utils/baseconv.pyi Normal file
View File

@@ -0,0 +1,10 @@
from typing import (
Tuple,
Union,
)
class BaseConverter:
def convert(self, number: Union[str, int], from_digits: str, to_digits: str, sign: str) -> Tuple[int, str]: ...
def decode(self, s: str) -> int: ...
def encode(self, i: int) -> str: ...

101
django/utils/cache.pyi Normal file
View File

@@ -0,0 +1,101 @@
from django.core.cache import DefaultCacheProxy
from django.core.cache.backends.locmem import LocMemCache
from django.core.handlers.wsgi import WSGIRequest
from django.http.response import (
HttpResponse,
HttpResponseBase,
HttpResponseNotModified,
)
from typing import (
List,
Optional,
Tuple,
Union,
)
def _generate_cache_header_key(key_prefix: str, request: WSGIRequest) -> str: ...
def _generate_cache_key(
request: WSGIRequest,
method: str,
headerlist: List[str],
key_prefix: str
) -> str: ...
def _i18n_cache_key_suffix(request: WSGIRequest, cache_key: str) -> str: ...
def _if_match_passes(target_etag: Optional[str], etags: List[str]) -> bool: ...
def _if_modified_since_passes(last_modified: Optional[int], if_modified_since: int) -> bool: ...
def _if_none_match_passes(target_etag: Optional[str], etags: List[str]) -> bool: ...
def _if_unmodified_since_passes(last_modified: int, if_unmodified_since: int) -> bool: ...
def _not_modified(
request: WSGIRequest,
response: Optional[HttpResponse] = ...
) -> HttpResponseNotModified: ...
def _precondition_failed(request: WSGIRequest) -> HttpResponse: ...
def _to_tuple(s: str) -> Union[Tuple[str, str], Tuple[str, bool]]: ...
def add_never_cache_headers(response: HttpResponse) -> None: ...
def get_cache_key(
request: WSGIRequest,
key_prefix: Optional[str] = ...,
method: str = ...,
cache: Optional[Union[DefaultCacheProxy, backends.locmem.LocMemCache]] = ...
) -> Optional[str]: ...
def get_conditional_response(
request: WSGIRequest,
etag: Optional[str] = ...,
last_modified: Optional[int] = ...,
response: Optional[HttpResponse] = ...
) -> Optional[HttpResponse]: ...
def get_max_age(response: HttpResponse) -> Optional[int]: ...
def has_vary_header(response: HttpResponse, header_query: str) -> bool: ...
def learn_cache_key(
request: WSGIRequest,
response: HttpResponse,
cache_timeout: Optional[Union[float, int]] = ...,
key_prefix: Optional[str] = ...,
cache: Optional[Union[DefaultCacheProxy, backends.locmem.LocMemCache]] = ...
) -> str: ...
def patch_cache_control(response: HttpResponseBase, **kwargs) -> None: ...
def patch_response_headers(response: HttpResponse, cache_timeout: int = ...) -> None: ...
def patch_vary_headers(
response: HttpResponseBase,
newheaders: Union[Tuple[str], Tuple[str, str]]
) -> None: ...
def set_response_etag(response: HttpResponse) -> HttpResponse: ...

18
django/utils/crypto.pyi Normal file
View File

@@ -0,0 +1,18 @@
from hmac import HMAC
from typing import (
Callable,
Optional,
Union,
)
def constant_time_compare(val1: Union[str, bytes], val2: Union[str, bytes]) -> bool: ...
def get_random_string(length: int = ..., allowed_chars: str = ...) -> str: ...
def pbkdf2(password: str, salt: str, iterations: int, dklen: int = ..., digest: Callable = ...) -> bytes: ...
def salted_hmac(key_salt: str, value: Union[str, bytes], secret: Optional[Union[str, bytes]] = ...) -> HMAC: ...

View File

@@ -0,0 +1,8 @@
from typing import (
Optional,
Union,
)
class DictWrapper:
def __getitem__(self, key: str) -> Optional[Union[str, int]]: ...

View File

@@ -0,0 +1,52 @@
from datetime import (
date,
time,
)
from typing import Union
def format(value: Union[time, str, date], format_string: str) -> str: ...
def time_format(value: Union[date, time, str], format_string: str) -> str: ...
class DateFormat:
def I(self) -> str: ...
def L(self) -> bool: ...
def M(self) -> str: ...
def S(self) -> str: ...
def U(self) -> int: ...
def Y(self) -> int: ...
def c(self) -> str: ...
def d(self) -> str: ...
def j(self) -> int: ...
def m(self) -> str: ...
def n(self) -> int: ...
def o(self) -> int: ...
def r(self) -> str: ...
def t(self) -> str: ...
def y(self) -> str: ...
class Formatter:
def format(self, formatstr: str) -> str: ...
class TimeFormat:
def A(self) -> str: ...
def G(self) -> int: ...
def H(self) -> str: ...
def O(self) -> str: ...
def P(self) -> str: ...
def T(self) -> str: ...
def Z(self) -> Union[str, int]: ...
def __init__(self, obj: Union[time, date, str]) -> None: ...
def a(self) -> str: ...
def e(self) -> str: ...
def f(self) -> Union[str, int]: ...
def g(self) -> int: ...
def h(self) -> str: ...
def i(self) -> str: ...
def s(self) -> str: ...
def u(self) -> str: ...

View File

@@ -0,0 +1,19 @@
from datetime import (
date,
datetime,
time,
timedelta,
)
from typing import Optional
def parse_date(value: str) -> Optional[date]: ...
def parse_datetime(value: str) -> datetime: ...
def parse_duration(value: str) -> Optional[timedelta]: ...
def parse_time(value: str) -> Optional[time]: ...

View File

@@ -0,0 +1,28 @@
from datetime import (
date,
datetime,
)
from typing import (
List,
Union,
)
def _findall(text: str, substr: str) -> List[int]: ...
def new_date(d: date) -> date: ...
def new_datetime(d: datetime) -> datetime: ...
def strftime(dt: Union[date, datetime], fmt: str) -> str: ...
class date:
def strftime(self, fmt: str) -> str: ...
class datetime:
def strftime(self, fmt: str) -> str: ...

View File

@@ -0,0 +1,12 @@
from django.contrib.postgres.validators import KeysValidator
from django.core.validators import RegexValidator
from typing import (
Type,
Union,
)
def deconstructible(
*args,
path = ...
) -> Type[Union[KeysValidator, RegexValidator]]: ...

View File

@@ -0,0 +1,37 @@
from django.middleware.cache import CacheMiddleware
from django.middleware.csrf import CsrfViewMiddleware
from typing import (
Any,
Callable,
Tuple,
Type,
Union,
)
def _multi_decorate(decorators: Union[Tuple[Callable, Callable], Callable], method: Callable) -> Callable: ...
def _update_method_wrapper(_wrapper: Callable, decorator: Callable) -> None: ...
def decorator_from_middleware(middleware_class: Type[CsrfViewMiddleware]) -> Callable: ...
def decorator_from_middleware_with_args(middleware_class: Type[CacheMiddleware]) -> Callable: ...
def make_middleware_decorator(middleware_class: Any) -> Callable: ...
def method_decorator(decorator: Callable, name: str = ...) -> Callable: ...
class classonlymethod:
def __get__(self, instance: None, cls: Any = ...) -> Callable: ...
class classproperty:
def __get__(self, instance: Any, cls: Any = ...) -> str: ...
def __init__(self, method: Callable = ...) -> None: ...
def getter(self, method: Callable) -> classproperty: ...

View File

@@ -0,0 +1,23 @@
from django.core.handlers.wsgi import WSGIRequest
from django.http.response import HttpResponseBase
from typing import (
Callable,
Optional,
Type,
)
class MiddlewareMixin:
def __call__(self, request: WSGIRequest) -> HttpResponseBase: ...
def __init__(self, get_response: Optional[Callable] = ...) -> None: ...
class warn_about_renamed_method:
def __call__(self, f: Callable) -> Callable: ...
def __init__(
self,
class_name: str,
old_method_name: str,
new_method_name: str,
deprecation_warning: Type[DeprecationWarning]
) -> None: ...

14
django/utils/duration.pyi Normal file
View File

@@ -0,0 +1,14 @@
from datetime import timedelta
from typing import Tuple
def _get_duration_components(duration: timedelta) -> Tuple[int, int, int, int, int]: ...
def duration_iso_string(duration: timedelta) -> str: ...
def duration_microseconds(delta: timedelta) -> int: ...
def duration_string(duration: timedelta) -> str: ...

46
django/utils/encoding.pyi Normal file
View File

@@ -0,0 +1,46 @@
from datetime import date
from typing import (
Any,
Optional,
Union,
)
def escape_uri_path(path: str) -> str: ...
def filepath_to_uri(path: Optional[str]) -> Optional[str]: ...
def force_bytes(
s: Any,
encoding: str = ...,
strings_only: bool = ...,
errors: str = ...
) -> Union[date, bytes]: ...
def force_text(s: Any, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> Optional[str]: ...
def get_system_encoding() -> str: ...
def iri_to_uri(iri: Optional[str]) -> Optional[str]: ...
def is_protected_type(obj: Any) -> bool: ...
def repercent_broken_unicode(path: bytes) -> bytes: ...
def smart_text(s: Any, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> str: ...
def uri_to_iri(uri: Optional[str]) -> Optional[str]: ...
class DjangoUnicodeDecodeError:
def __init__(self, obj: bytes, *args) -> None: ...
def __str__(self) -> str: ...

View File

@@ -0,0 +1,96 @@
from io import StringIO
from datetime import (
date,
datetime,
)
from django.http.response import HttpResponse
from django.utils.safestring import SafeText
from django.utils.xmlutils import SimplerXMLGenerator
from typing import (
Any,
Dict,
List,
Optional,
Tuple,
Union,
)
def get_tag_uri(url: str, date: datetime) -> str: ...
def rfc2822_date(date: date) -> str: ...
def rfc3339_date(date: datetime) -> str: ...
class Atom1Feed:
def add_item_elements(self, handler: SimplerXMLGenerator, item: Dict[str, Any]) -> None: ...
def add_root_elements(self, handler: SimplerXMLGenerator) -> None: ...
def root_attributes(self) -> Dict[str, str]: ...
def write(self, outfile: Union[StringIO, HttpResponse], encoding: str) -> None: ...
def write_items(self, handler: SimplerXMLGenerator) -> None: ...
class Enclosure:
def __init__(self, url: str, length: Union[str, int], mime_type: str) -> None: ...
class Rss201rev2Feed:
def add_item_elements(self, handler: SimplerXMLGenerator, item: Dict[str, Any]) -> None: ...
class RssFeed:
def add_root_elements(self, handler: SimplerXMLGenerator) -> None: ...
def endChannelElement(self, handler: SimplerXMLGenerator) -> None: ...
def rss_attributes(self) -> Dict[str, str]: ...
def write(self, outfile: HttpResponse, encoding: str) -> None: ...
def write_items(self, handler: SimplerXMLGenerator) -> None: ...
class RssUserland091Feed:
def add_item_elements(self, handler: SimplerXMLGenerator, item: Dict[str, Any]) -> None: ...
class SyndicationFeed:
def __init__(
self,
title: str,
link: str,
description: str,
language: Optional[str] = ...,
author_email: Optional[str] = ...,
author_name: Optional[str] = ...,
author_link: Optional[str] = ...,
subtitle: Optional[str] = ...,
categories: Optional[Tuple[str, str]] = ...,
feed_url: Optional[str] = ...,
feed_copyright: Optional[str] = ...,
feed_guid: Optional[str] = ...,
ttl: Optional[int] = ...,
**kwargs
) -> None: ...
def add_item(
self,
title: SafeText,
link: str,
description: str,
author_email: Optional[str] = ...,
author_name: Optional[str] = ...,
author_link: Optional[str] = ...,
pubdate: Optional[datetime] = ...,
comments: None = ...,
unique_id: str = ...,
unique_id_is_permalink: Optional[bool] = ...,
categories: Optional[Tuple[str, str]] = ...,
item_copyright: Optional[str] = ...,
ttl: None = ...,
updateddate: Optional[datetime] = ...,
enclosures: List[Enclosure] = ...,
**kwargs
) -> None: ...
def item_attributes(self, item: Dict[str, Any]) -> Dict[Any, Any]: ...
def latest_post_date(self) -> datetime: ...
def root_attributes(self) -> Dict[Any, Any]: ...
def writeString(self, encoding: str) -> str: ...

59
django/utils/formats.pyi Normal file
View File

@@ -0,0 +1,59 @@
from datetime import (
date,
time,
)
from decimal import Decimal
from typing import (
Any,
Iterator,
List,
Optional,
Union,
)
def date_format(
value: Union[time, date, str],
format: Optional[str] = ...,
use_l10n: Optional[bool] = ...
) -> str: ...
def get_format(
format_type: str,
lang: Optional[str] = ...,
use_l10n: Optional[bool] = ...
) -> Union[str, List[str], int]: ...
def get_format_modules(lang: str = ..., reverse: bool = ...) -> List[Any]: ...
def iter_format_modules(lang: str, format_module_path: Optional[str] = ...) -> Iterator[Any]: ...
def localize(value: Any, use_l10n: Optional[bool] = ...) -> Any: ...
def localize_input(value: Any, default: Optional[str] = ...) -> Optional[str]: ...
def number_format(
value: Union[Decimal, float, str, int],
decimal_pos: Optional[int] = ...,
use_l10n: Optional[bool] = ...,
force_grouping: bool = ...
) -> str: ...
def reset_format_cache() -> None: ...
def sanitize_separators(value: Union[str, int]) -> Union[str, int]: ...
def time_format(
value: Union[date, time, str],
format: Optional[str] = ...,
use_l10n: None = ...
) -> str: ...

View File

@@ -0,0 +1,24 @@
from typing import (
Any,
Callable,
Dict,
List,
)
class LazyObject:
def __delattr__(self, name: str) -> None: ...
def __init__(self) -> None: ...
def __reduce__(self) -> Any: ...
def __setattr__(self, name: str, value: object) -> None: ...
class SimpleLazyObject:
def __copy__(self) -> object: ...
def __deepcopy__(self, memo: Dict[Any, Any]) -> List[int]: ...
def __init__(self, func: Callable) -> None: ...
def _setup(self) -> None: ...
class cached_property:
def __get__(self, instance: Any, cls: Any = ...) -> Any: ...

65
django/utils/html.pyi Normal file
View File

@@ -0,0 +1,65 @@
from django.utils.safestring import SafeText
from typing import (
Any,
Dict,
List,
Optional,
Tuple,
Union,
)
def _strip_once(value: str) -> str: ...
def avoid_wrapping(value: str) -> str: ...
def conditional_escape(text: Any) -> str: ...
def escape(text: Any) -> SafeText: ...
def escapejs(value: str) -> SafeText: ...
def format_html(format_string: str, *args, **kwargs) -> SafeText: ...
def format_html_join(
sep: str,
format_string: str,
args_generator: Union[List[Tuple[str]], List[Tuple[str, str]]]
) -> SafeText: ...
def json_script(value: Dict[str, str], element_id: SafeText) -> SafeText: ...
def linebreaks(value: str, autoescape: bool = ...) -> str: ...
def smart_urlquote(url: str) -> str: ...
def strip_spaces_between_tags(value: str) -> str: ...
def strip_tags(value: str) -> str: ...
def urlize(
text: str,
trim_url_limit: Optional[int] = ...,
nofollow: bool = ...,
autoescape: bool = ...
) -> str: ...
class MLStripper:
def __init__(self) -> None: ...
def get_data(self) -> str: ...
def handle_charref(self, name: str) -> None: ...
def handle_data(self, d: str) -> None: ...
def handle_entityref(self, name: str) -> None: ...

79
django/utils/http.pyi Normal file
View File

@@ -0,0 +1,79 @@
from typing import (
Any,
Dict,
List,
Optional,
Set,
Tuple,
Union,
)
from urllib.parse import (
ParseResult,
SplitResult,
)
def _is_safe_url(url: str, allowed_hosts: Set[str], require_https: bool = ...) -> bool: ...
def _urlparse(url: str, scheme: str = ..., allow_fragments: bool = ...) -> ParseResult: ...
def _urlsplit(url: str, scheme: str = ..., allow_fragments: bool = ...) -> SplitResult: ...
def base36_to_int(s: str) -> int: ...
def cookie_date(epoch_seconds: float = ...) -> str: ...
def http_date(epoch_seconds: Union[float, int] = ...) -> str: ...
def int_to_base36(i: Union[str, int, Dict[int, int]]) -> str: ...
def is_safe_url(url: Optional[str], allowed_hosts: Optional[Set[str]], require_https: bool = ...) -> bool: ...
def is_same_domain(host: str, pattern: str) -> bool: ...
def limited_parse_qsl(
qs: str,
keep_blank_values: bool = ...,
encoding: str = ...,
errors: str = ...,
fields_limit: Optional[int] = ...
) -> List[Tuple[str, str]]: ...
def parse_etags(etag_str: str) -> List[str]: ...
def parse_http_date(date: str) -> int: ...
def parse_http_date_safe(date: str) -> int: ...
def quote_etag(etag_str: str) -> str: ...
def urlencode(query: Any, doseq: bool = ...) -> str: ...
def urlquote(url: str, safe: str = ...) -> str: ...
def urlquote_plus(url: str, safe: str = ...) -> str: ...
def urlsafe_base64_decode(s: Union[str, bytes]) -> bytes: ...
def urlsafe_base64_encode(s: bytes) -> bytes: ...
def urlunquote_plus(quoted_url: str) -> str: ...

16
django/utils/inspect.pyi Normal file
View File

@@ -0,0 +1,16 @@
from typing import (
Callable,
List,
)
def func_accepts_kwargs(func: Callable) -> bool: ...
def func_accepts_var_args(func: Callable) -> bool: ...
def func_supports_parameter(func: Callable, parameter: str) -> bool: ...
def get_func_args(func: Callable) -> List[str]: ...

1
django/utils/ipv6.pyi Normal file
View File

@@ -0,0 +1 @@
def is_valid_ipv6_address(ip_str: str) -> bool: ...

View File

@@ -0,0 +1,4 @@
from typing import Any
def is_iterable(x: Any) -> bool: ...

26
django/utils/jslex.pyi Normal file
View File

@@ -0,0 +1,26 @@
from typing import (
Dict,
Iterator,
List,
Optional,
Tuple,
)
def literals(choices: str, prefix: str = ..., suffix: str = ...) -> str: ...
def prepare_js_for_gettext(js: str) -> str: ...
class JsLexer:
def __init__(self) -> None: ...
class Lexer:
def __init__(self, states: Dict[str, List[Tok]], first: str) -> None: ...
def lex(self, text: str) -> Iterator[Tuple[str, str]]: ...
class Tok:
def __init__(self, name: str, regex: str, next: Optional[str] = ...) -> None: ...

49
django/utils/log.pyi Normal file
View File

@@ -0,0 +1,49 @@
from django.core.mail.backends.locmem import EmailBackend
from logging import LogRecord
from typing import (
Any,
Callable,
Dict,
Union,
)
def configure_logging(logging_config: str, logging_settings: Dict[str, Any]) -> None: ...
def log_response(
message: str,
*args,
response = ...,
request = ...,
logger = ...,
level = ...,
exc_info = ...
) -> None: ...
class AdminEmailHandler:
def __init__(self, include_html: bool = ..., email_backend: None = ...) -> None: ...
def connection(self) -> EmailBackend: ...
def emit(self, record: LogRecord) -> None: ...
def format_subject(self, subject: str) -> str: ...
def send_mail(self, subject: str, message: str, *args, **kwargs) -> None: ...
class CallbackFilter:
def __init__(self, callback: Callable) -> None: ...
def filter(self, record: str) -> int: ...
class RequireDebugFalse:
def filter(self, record: Union[str, LogRecord]) -> bool: ...
class RequireDebugTrue:
def filter(self, record: LogRecord) -> bool: ...
class ServerFormatter:
def __init__(self, *args, **kwargs) -> None: ...
def format(self, record: LogRecord) -> str: ...
def uses_server_time(self) -> bool: ...

View File

@@ -0,0 +1,7 @@
def paragraph() -> str: ...
def sentence() -> str: ...
def words(count: int, common: bool = ...) -> str: ...

View File

@@ -0,0 +1,13 @@
from typing import Any
def autodiscover_modules(*args, **kwargs) -> None: ...
def import_string(dotted_path: str) -> object: ...
def module_dir(module: Any) -> str: ...
def module_has_submodule(package: Any, module_name: str) -> bool: ...

View File

@@ -0,0 +1,17 @@
from decimal import Decimal
from typing import (
Optional,
Tuple,
Union,
)
def format(
number: Union[float, str, int, Decimal],
decimal_sep: str,
decimal_pos: Optional[int] = ...,
grouping: Union[Tuple[int, int, int], int, Tuple[int, int, int, int, int]] = ...,
thousand_sep: str = ...,
force_grouping: bool = ...,
use_l10n: Optional[bool] = ...
) -> str: ...

View File

@@ -0,0 +1,28 @@
from typing import (
Any,
Iterator,
List,
Tuple,
Type,
Union,
)
def contains(
source: Union[str, Group, NonCapture],
inst: Type[Group]
) -> bool: ...
def flatten_result(source: Any) -> Union[Tuple[List[str], List[List[str]]], Tuple[List[str], List[List[Any]]]]: ...
def get_quantifier(ch: str, input_iter: Iterator[Any]) -> Union[Tuple[int, None], Tuple[int, str]]: ...
def normalize(
pattern: str
) -> Union[List[Tuple[str, List[Any]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[str]]]], List[Tuple[str, List[str]]]]: ...
def walk_to_end(ch: str, input_iter: Iterator[Any]) -> None: ...

View File

@@ -0,0 +1,22 @@
from django.forms.boundfield import BoundField
from typing import (
Callable,
Union,
)
def _safety_decorator(safety_marker: Callable, func: Callable) -> Callable: ...
def mark_safe(
s: Union[str, Callable, BoundField]
) -> Union[SafeText, Callable, BoundField]: ...
class SafeData:
def __html__(self) -> SafeText: ...
class SafeText:
def __add__(self, rhs: str) -> str: ...
def __str__(self) -> SafeText: ...

14
django/utils/six.pyi Normal file
View File

@@ -0,0 +1,14 @@
from _frozen_importlib_external import _NamespacePath
from typing import (
List,
Optional,
Union,
)
class _SixMetaPathImporter:
def find_module(
self,
fullname: str,
path: Optional[Union[List[str], _NamespacePath]] = ...
) -> None: ...

View File

@@ -0,0 +1,18 @@
from typing import (
Callable,
Dict,
Optional,
Tuple,
Union,
)
def colorize(text: str = ..., opts: Union[str, Tuple] = ..., **kwargs) -> str: ...
def make_style(opts: Tuple = ..., **kwargs) -> Callable: ...
def parse_color_setting(
config_string: str
) -> Optional[Union[Dict[str, Dict[str, str]], Dict[str, Dict[str, Union[str, Tuple[str]]]]]]: ...

65
django/utils/text.pyi Normal file
View File

@@ -0,0 +1,65 @@
from django.utils.safestring import SafeText
from typing import (
Iterator,
List,
Optional,
Union,
)
def _format_lazy(format_string: str, *args, **kwargs) -> str: ...
def camel_case_to_spaces(value: str) -> str: ...
def capfirst(x: Optional[str]) -> Optional[str]: ...
def compress_sequence(sequence: Union[List[bytes], map]) -> Iterator[bytes]: ...
def compress_string(s: bytes) -> bytes: ...
def get_text_list(list_: List[str], last_word: str = ...) -> str: ...
def get_valid_filename(s: str) -> str: ...
def normalize_newlines(text: str) -> str: ...
def phone2numeric(phone: str) -> str: ...
def slugify(value: str, allow_unicode: bool = ...) -> SafeText: ...
def smart_split(text: str) -> Iterator[str]: ...
def unescape_entities(text: str) -> str: ...
def unescape_string_literal(s: str) -> str: ...
def wrap(text: str, width: int) -> str: ...
class StreamingBuffer:
def __init__(self) -> None: ...
def read(self) -> bytes: ...
def write(self, val: bytes) -> None: ...
class Truncator:
def __init__(self, text: str) -> None: ...
def _text_chars(self, length: int, truncate: Optional[str], text: str, truncate_len: int) -> str: ...
def _text_words(self, length: int, truncate: Optional[str]) -> str: ...
def _truncate_html(self, length: int, truncate: Optional[str], text: str, truncate_len: int, words: bool) -> str: ...
def add_truncation_text(self, text: str, truncate: Optional[str] = ...) -> str: ...
def chars(self, num: int, truncate: Optional[str] = ..., html: bool = ...) -> str: ...
def words(self, num: int, truncate: Optional[str] = ..., html: bool = ...) -> str: ...

View File

@@ -0,0 +1,13 @@
from datetime import date
from typing import Optional
def timesince(
d: date,
now: Optional[date] = ...,
reversed: bool = ...,
time_strings: None = ...
) -> str: ...
def timeuntil(d: date, now: Optional[date] = ..., time_strings: None = ...) -> str: ...

69
django/utils/timezone.pyi Normal file
View File

@@ -0,0 +1,69 @@
from datetime import (
datetime,
time,
timedelta,
)
from typing import (
Any,
Optional,
Union,
)
def _get_timezone_name(timezone: FixedOffset) -> str: ...
def activate(timezone: Union[str, FixedOffset]) -> None: ...
def deactivate() -> None: ...
def get_current_timezone() -> FixedOffset: ...
def get_current_timezone_name() -> str: ...
def get_fixed_timezone(offset: int) -> FixedOffset: ...
def is_aware(value: Union[time, datetime]) -> bool: ...
def is_naive(value: datetime) -> bool: ...
def localtime(
value: Optional[datetime] = ...,
timezone: Optional[FixedOffset] = ...
) -> datetime: ...
def make_aware(
value: datetime,
timezone: Optional[FixedOffset] = ...,
is_dst: Optional[bool] = ...
) -> datetime: ...
def make_naive(value: datetime, timezone: FixedOffset = ...) -> datetime: ...
def now() -> datetime: ...
def template_localtime(value: Any, use_tz: Optional[bool] = ...) -> Any: ...
class FixedOffset:
def __init__(self, offset: Optional[int] = ..., name: Optional[str] = ...) -> None: ...
def dst(self, dt: datetime) -> timedelta: ...
def tzname(self, dt: Optional[datetime]) -> str: ...
def utcoffset(self, dt: datetime) -> timedelta: ...
class override:
def __enter__(self) -> None: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def __init__(self, timezone: Optional[Union[str, FixedOffset]]) -> None: ...

View File

@@ -0,0 +1,65 @@
from django.core.handlers.wsgi import WSGIRequest
from typing import (
Optional,
Union,
)
def activate(language: str) -> None: ...
def check_for_language(lang_code: Optional[str]) -> bool: ...
def deactivate() -> None: ...
def deactivate_all() -> None: ...
def get_language() -> Optional[str]: ...
def get_language_bidi() -> bool: ...
def get_language_from_path(path: str) -> Optional[str]: ...
def get_language_from_request(request: WSGIRequest, check_path: bool = ...) -> str: ...
def get_language_info(lang_code: str): ...
def gettext(message: str) -> str: ...
def gettext_noop(message: str) -> str: ...
def ngettext(singular: str, plural: str, number: Union[float, int]) -> str: ...
def npgettext(context: str, singular: str, plural: str, number: int) -> str: ...
def pgettext(context: str, message: str) -> str: ...
def templatize(src: str, **kwargs) -> str: ...
def to_language(locale: str) -> str: ...
def to_locale(language: str) -> str: ...
def trim_whitespace(s: str) -> str: ...
class override:
def __enter__(self) -> None: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def __init__(self, language: Optional[str], deactivate: bool = ...) -> None: ...

View File

@@ -0,0 +1,4 @@
def blankout(src: str, char: str) -> str: ...
def templatize(src: str, origin: str = ...) -> str: ...

View File

@@ -0,0 +1,10 @@
def check_for_language(x: str) -> bool: ...
def get_language_from_path(request: str) -> None: ...
def get_supported_language_variant(lang_code: str, strict: bool = ...) -> str: ...
def ngettext(singular: str, plural: str, number: int) -> str: ...

View File

@@ -0,0 +1,85 @@
from collections import OrderedDict
from django.core.handlers.wsgi import WSGIRequest
from gettext import NullTranslations
from typing import (
List,
Optional,
Tuple,
Union,
)
def activate(language: str) -> None: ...
def all_locale_paths() -> List[str]: ...
def check_for_language(lang_code: str) -> bool: ...
def deactivate() -> None: ...
def deactivate_all() -> None: ...
def do_ntranslate(singular: str, plural: str, number: Union[float, int], translation_function: str) -> str: ...
def get_language() -> Optional[str]: ...
def get_language_bidi() -> bool: ...
def get_language_from_path(path: str, strict: bool = ...) -> Optional[str]: ...
def get_language_from_request(request: WSGIRequest, check_path: bool = ...) -> str: ...
def get_languages() -> OrderedDict: ...
def get_supported_language_variant(lang_code: Optional[str], strict: bool = ...) -> str: ...
def gettext(message: str) -> str: ...
def gettext_noop(message: str) -> str: ...
def ngettext(singular: str, plural: str, number: Union[float, int]) -> str: ...
def npgettext(context: str, singular: str, plural: str, number: int) -> str: ...
def parse_accept_lang_header(lang_string: str) -> Tuple: ...
def pgettext(context: str, message: str) -> str: ...
def reset_cache(**kwargs) -> None: ...
def translation(language: str) -> DjangoTranslation: ...
class DjangoTranslation:
def __init__(
self,
language: str,
domain: Optional[str] = ...,
localedirs: Optional[List[str]] = ...
) -> None: ...
def _add_fallback(self, localedirs: Optional[List[str]] = ...) -> None: ...
def _add_installed_apps_translations(self) -> None: ...
def _add_local_translations(self) -> None: ...
def _init_translation_catalog(self) -> None: ...
def _new_gnu_trans(self, localedir: str, use_null_fallback: bool = ...) -> NullTranslations: ...
def merge(self, other: NullTranslations) -> None: ...
def to_language(self) -> str: ...

29
django/utils/tree.pyi Normal file
View File

@@ -0,0 +1,29 @@
from django.db.models.query_utils import Q
from django.db.models.sql.where import WhereNode
from typing import (
Any,
Dict,
Optional,
Tuple,
)
class Node:
def __bool__(self) -> bool: ...
def __contains__(self, other: Tuple[str, int]) -> bool: ...
def __deepcopy__(self, memodict: Dict[Any, Any]) -> Q: ...
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __init__(self, children: Any = ..., connector: Optional[str] = ..., negated: bool = ...) -> None: ...
def __len__(self) -> int: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
@classmethod
def _new_instance(
cls,
children: Any = ...,
connector: str = ...,
negated: bool = ...
) -> WhereNode: ...
def add(self, data: Any, conn_type: str, squash: bool = ...) -> Any: ...
def negate(self) -> None: ...

19
django/utils/version.pyi Normal file
View File

@@ -0,0 +1,19 @@
from typing import (
Optional,
Tuple,
)
def get_complete_version(version: Optional[Tuple[int, int, int, str, int]] = ...) -> Tuple[int, int, int, str, int]: ...
def get_docs_version(version: None = ...) -> str: ...
def get_git_changeset() -> str: ...
def get_main_version(version: Tuple[int, int, int, str, int] = ...) -> str: ...
def get_version(version: Optional[Tuple[int, int, int, str, int]] = ...) -> str: ...

15
django/utils/xmlutils.pyi Normal file
View File

@@ -0,0 +1,15 @@
from typing import (
Dict,
Optional,
)
class SimplerXMLGenerator:
def addQuickElement(
self,
name: str,
contents: Optional[str] = ...,
attrs: Optional[Dict[str, str]] = ...
) -> None: ...
def characters(self, content: str) -> None: ...
def startElement(self, name: str, attrs: Dict[str, str]) -> None: ...