diff --git a/django/urls/resolvers.pyi b/django/urls/resolvers.pyi new file mode 100644 index 0000000..3b450c8 --- /dev/null +++ b/django/urls/resolvers.pyi @@ -0,0 +1,119 @@ +from django.core.checks.messages import ( + Error, + Warning, +) +from django.utils.datastructures import MultiValueDict +from typing import ( + Any, + Callable, + Dict, + List, + Optional, + Tuple, + Type, + Union, +) + + +def _route_to_regex(route: str, is_endpoint: bool = ...) -> Any: ... + + +def get_ns_resolver( + ns_pattern: str, + resolver: URLResolver, + converters: Tuple +) -> URLResolver: ... + + +def get_resolver(urlconf: Optional[Union[str, Type[object]]] = ...) -> URLResolver: ... + + +class CheckURLMixin: + def _check_pattern_startswith_slash(self) -> List[Any]: ... + def describe(self) -> str: ... + + +class LocalePrefixPattern: + def __init__(self, prefix_default_language: bool = ...) -> None: ... + def __str__(self) -> str: ... + def describe(self) -> str: ... + @property + def language_prefix(self) -> str: ... + def match(self, path: str) -> Optional[Tuple[str, Tuple, Dict[Any, Any]]]: ... + + +class RegexPattern: + def __init__(self, regex: str, name: Optional[str] = ..., is_endpoint: bool = ...) -> None: ... + def __str__(self) -> str: ... + def _check_include_trailing_dollar(self) -> List[Any]: ... + def _compile(self, regex: str): ... + def check(self) -> List[Any]: ... + def match(self, path: str) -> Any: ... + + +class ResolverMatch: + def __getitem__(self, index: int) -> Any: ... + def __init__( + self, + func: Callable, + args: Tuple, + kwargs: Dict[str, Any], + url_name: Optional[str] = ..., + app_names: Optional[Union[List[str], List[Union[None, str]], List[None]]] = ..., + namespaces: Optional[Union[List[str], List[Union[None, str]], List[None]]] = ... + ) -> None: ... + def __repr__(self) -> str: ... + + +class RoutePattern: + def __init__(self, route: str, name: Optional[str] = ..., is_endpoint: bool = ...) -> None: ... + def __str__(self) -> str: ... + def check(self) -> List[Warning]: ... + def match(self, path: str) -> Any: ... + + +class URLPattern: + def __init__( + self, + pattern: CheckURLMixin, + callback: Callable, + default_args: Any = ..., + name: Optional[str] = ... + ) -> None: ... + def __repr__(self) -> str: ... + def _check_pattern_name(self) -> List[Any]: ... + def check(self) -> List[Warning]: ... + @cached_property + def lookup_str(self) -> str: ... + def resolve(self, path: str) -> Optional[ResolverMatch]: ... + + +class URLResolver: + def __init__( + self, + pattern: Union[LocalePrefixPattern, CheckURLMixin], + urlconf_name: Any, + default_kwargs: None = ..., + app_name: Optional[str] = ..., + namespace: Optional[str] = ... + ) -> None: ... + def __repr__(self) -> str: ... + def _is_callback(self, name: str) -> bool: ... + def _populate(self) -> None: ... + def _reverse_with_prefix(self, lookup_view: Optional[str], _prefix: str, *args, **kwargs) -> str: ... + @property + def app_dict(self) -> Dict[str, List[str]]: ... + def check(self) -> Union[List[Warning], List[Error]]: ... + @property + def namespace_dict(self) -> Dict[str, Tuple[str, URLResolver]]: ... + def resolve(self, path: str) -> ResolverMatch: ... + def resolve_error_handler(self, view_type: int) -> Tuple[Callable, Dict[Any, Any]]: ... + def reverse(self, lookup_view: str, *args, **kwargs) -> str: ... + @property + def reverse_dict(self) -> MultiValueDict: ... + @cached_property + def url_patterns( + self + ) -> Union[List[URLResolver], List[Union[URLPattern, URLResolver]], List[URLPattern], List[Tuple[str, Callable]]]: ... + @cached_property + def urlconf_module(self) -> Any: ... \ No newline at end of file diff --git a/django/urls/utils.pyi b/django/urls/utils.pyi new file mode 100644 index 0000000..f675eb4 --- /dev/null +++ b/django/urls/utils.pyi @@ -0,0 +1,11 @@ +from typing import ( + Callable, + Tuple, + Union, +) + + +def get_callable(lookup_view: Union[str, Callable]) -> Callable: ... + + +def get_mod_func(callback: str) -> Tuple[str, str]: ... \ No newline at end of file diff --git a/django/utils/_os.pyi b/django/utils/_os.pyi new file mode 100644 index 0000000..6ff905d --- /dev/null +++ b/django/utils/_os.pyi @@ -0,0 +1,4 @@ +def safe_join(base: str, *paths) -> str: ... + + +def symlinks_supported(): ... \ No newline at end of file diff --git a/django/utils/archive.pyi b/django/utils/archive.pyi new file mode 100644 index 0000000..cf7f678 --- /dev/null +++ b/django/utils/archive.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/autoreload.pyi b/django/utils/autoreload.pyi new file mode 100644 index 0000000..94041af --- /dev/null +++ b/django/utils/autoreload.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/baseconv.pyi b/django/utils/baseconv.pyi new file mode 100644 index 0000000..d60f6e9 --- /dev/null +++ b/django/utils/baseconv.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/cache.pyi b/django/utils/cache.pyi new file mode 100644 index 0000000..6c55897 --- /dev/null +++ b/django/utils/cache.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/crypto.pyi b/django/utils/crypto.pyi new file mode 100644 index 0000000..5d12d91 --- /dev/null +++ b/django/utils/crypto.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/datastructures.pyi b/django/utils/datastructures.pyi new file mode 100644 index 0000000..38ec82a --- /dev/null +++ b/django/utils/datastructures.pyi @@ -0,0 +1,8 @@ +from typing import ( + Optional, + Union, +) + + +class DictWrapper: + def __getitem__(self, key: str) -> Optional[Union[str, int]]: ... \ No newline at end of file diff --git a/django/utils/dateformat.pyi b/django/utils/dateformat.pyi new file mode 100644 index 0000000..d8459dc --- /dev/null +++ b/django/utils/dateformat.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/dateparse.pyi b/django/utils/dateparse.pyi new file mode 100644 index 0000000..e63c1b2 --- /dev/null +++ b/django/utils/dateparse.pyi @@ -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]: ... \ No newline at end of file diff --git a/django/utils/datetime_safe.pyi b/django/utils/datetime_safe.pyi new file mode 100644 index 0000000..db0b925 --- /dev/null +++ b/django/utils/datetime_safe.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/deconstruct.pyi b/django/utils/deconstruct.pyi new file mode 100644 index 0000000..01adace --- /dev/null +++ b/django/utils/deconstruct.pyi @@ -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]]: ... \ No newline at end of file diff --git a/django/utils/decorators.pyi b/django/utils/decorators.pyi new file mode 100644 index 0000000..d8e238a --- /dev/null +++ b/django/utils/decorators.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/deprecation.pyi b/django/utils/deprecation.pyi new file mode 100644 index 0000000..6c4c4fe --- /dev/null +++ b/django/utils/deprecation.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/duration.pyi b/django/utils/duration.pyi new file mode 100644 index 0000000..ef999f5 --- /dev/null +++ b/django/utils/duration.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/encoding.pyi b/django/utils/encoding.pyi new file mode 100644 index 0000000..3496ae2 --- /dev/null +++ b/django/utils/encoding.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/feedgenerator.pyi b/django/utils/feedgenerator.pyi new file mode 100644 index 0000000..2e66203 --- /dev/null +++ b/django/utils/feedgenerator.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/formats.pyi b/django/utils/formats.pyi new file mode 100644 index 0000000..0b043a2 --- /dev/null +++ b/django/utils/formats.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/functional.pyi b/django/utils/functional.pyi new file mode 100644 index 0000000..55c30f8 --- /dev/null +++ b/django/utils/functional.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/html.pyi b/django/utils/html.pyi new file mode 100644 index 0000000..c85cb79 --- /dev/null +++ b/django/utils/html.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/http.pyi b/django/utils/http.pyi new file mode 100644 index 0000000..6daa12c --- /dev/null +++ b/django/utils/http.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/inspect.pyi b/django/utils/inspect.pyi new file mode 100644 index 0000000..b0b975d --- /dev/null +++ b/django/utils/inspect.pyi @@ -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]: ... \ No newline at end of file diff --git a/django/utils/ipv6.pyi b/django/utils/ipv6.pyi new file mode 100644 index 0000000..f792b93 --- /dev/null +++ b/django/utils/ipv6.pyi @@ -0,0 +1 @@ +def is_valid_ipv6_address(ip_str: str) -> bool: ... \ No newline at end of file diff --git a/django/utils/itercompat.pyi b/django/utils/itercompat.pyi new file mode 100644 index 0000000..9fc87c5 --- /dev/null +++ b/django/utils/itercompat.pyi @@ -0,0 +1,4 @@ +from typing import Any + + +def is_iterable(x: Any) -> bool: ... \ No newline at end of file diff --git a/django/utils/jslex.pyi b/django/utils/jslex.pyi new file mode 100644 index 0000000..6d1caab --- /dev/null +++ b/django/utils/jslex.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/log.pyi b/django/utils/log.pyi new file mode 100644 index 0000000..ceab0de --- /dev/null +++ b/django/utils/log.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/lorem_ipsum.pyi b/django/utils/lorem_ipsum.pyi new file mode 100644 index 0000000..6f2cbb9 --- /dev/null +++ b/django/utils/lorem_ipsum.pyi @@ -0,0 +1,7 @@ +def paragraph() -> str: ... + + +def sentence() -> str: ... + + +def words(count: int, common: bool = ...) -> str: ... \ No newline at end of file diff --git a/django/utils/module_loading.pyi b/django/utils/module_loading.pyi new file mode 100644 index 0000000..e139ea3 --- /dev/null +++ b/django/utils/module_loading.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/numberformat.pyi b/django/utils/numberformat.pyi new file mode 100644 index 0000000..6f3d884 --- /dev/null +++ b/django/utils/numberformat.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/regex_helper.pyi b/django/utils/regex_helper.pyi new file mode 100644 index 0000000..02d428b --- /dev/null +++ b/django/utils/regex_helper.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/safestring.pyi b/django/utils/safestring.pyi new file mode 100644 index 0000000..7c25acc --- /dev/null +++ b/django/utils/safestring.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/six.pyi b/django/utils/six.pyi new file mode 100644 index 0000000..6785f23 --- /dev/null +++ b/django/utils/six.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/termcolors.pyi b/django/utils/termcolors.pyi new file mode 100644 index 0000000..34b08ac --- /dev/null +++ b/django/utils/termcolors.pyi @@ -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]]]]]]: ... \ No newline at end of file diff --git a/django/utils/text.pyi b/django/utils/text.pyi new file mode 100644 index 0000000..30e9147 --- /dev/null +++ b/django/utils/text.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/timesince.pyi b/django/utils/timesince.pyi new file mode 100644 index 0000000..8e59ba1 --- /dev/null +++ b/django/utils/timesince.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/timezone.pyi b/django/utils/timezone.pyi new file mode 100644 index 0000000..aa22c3f --- /dev/null +++ b/django/utils/timezone.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/translation/__init__.pyi b/django/utils/translation/__init__.pyi new file mode 100644 index 0000000..567bf77 --- /dev/null +++ b/django/utils/translation/__init__.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/translation/template.pyi b/django/utils/translation/template.pyi new file mode 100644 index 0000000..afac7d6 --- /dev/null +++ b/django/utils/translation/template.pyi @@ -0,0 +1,4 @@ +def blankout(src: str, char: str) -> str: ... + + +def templatize(src: str, origin: str = ...) -> str: ... \ No newline at end of file diff --git a/django/utils/translation/trans_null.pyi b/django/utils/translation/trans_null.pyi new file mode 100644 index 0000000..d0004b6 --- /dev/null +++ b/django/utils/translation/trans_null.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/translation/trans_real.pyi b/django/utils/translation/trans_real.pyi new file mode 100644 index 0000000..aec796e --- /dev/null +++ b/django/utils/translation/trans_real.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/tree.pyi b/django/utils/tree.pyi new file mode 100644 index 0000000..800c914 --- /dev/null +++ b/django/utils/tree.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/version.pyi b/django/utils/version.pyi new file mode 100644 index 0000000..03a727a --- /dev/null +++ b/django/utils/version.pyi @@ -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: ... \ No newline at end of file diff --git a/django/utils/xmlutils.pyi b/django/utils/xmlutils.pyi new file mode 100644 index 0000000..1890551 --- /dev/null +++ b/django/utils/xmlutils.pyi @@ -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: ... \ No newline at end of file diff --git a/django/views/csrf.pyi b/django/views/csrf.pyi new file mode 100644 index 0000000..c9db637 --- /dev/null +++ b/django/views/csrf.pyi @@ -0,0 +1,9 @@ +from django.http.request import HttpRequest +from django.http.response import HttpResponseForbidden + + +def csrf_failure( + request: HttpRequest, + reason: str = ..., + template_name: str = ... +) -> HttpResponseForbidden: ... \ No newline at end of file diff --git a/django/views/debug.pyi b/django/views/debug.pyi new file mode 100644 index 0000000..74d3aa4 --- /dev/null +++ b/django/views/debug.pyi @@ -0,0 +1,80 @@ +from _frozen_importlib import FrozenImporter +from _frozen_importlib_external import SourceFileLoader +from django.core.handlers.wsgi import WSGIRequest +from django.http.request import QueryDict +from django.http.response import ( + Http404, + HttpResponseNotFound, +) +from django.utils.safestring import SafeText +from typing import ( + Any, + Dict, + List, + Optional, + Tuple, + Type, + Union, +) + + +def cleanse_setting(key: Union[str, int], value: Any) -> Any: ... + + +def get_default_exception_reporter_filter() -> SafeExceptionReporterFilter: ... + + +def get_exception_reporter_filter( + request: Optional[WSGIRequest] +) -> SafeExceptionReporterFilter: ... + + +def get_safe_settings() -> Dict[str, Any]: ... + + +def technical_404_response( + request: WSGIRequest, + exception: Http404 +) -> HttpResponseNotFound: ... + + +class CallableSettingWrapper: + def __init__(self, callable_setting: Type[object]) -> None: ... + def __repr__(self) -> str: ... + + +class ExceptionReporter: + def __init__( + self, + request: Optional[WSGIRequest], + exc_type: None, + exc_value: Optional[str], + tb: None, + is_email: bool = ... + ) -> None: ... + def _get_lines_from_file( + self, + filename: str, + lineno: int, + context_lines: int, + loader: Optional[Union[SourceFileLoader, Type[FrozenImporter]]] = ..., + module_name: str = ... + ) -> Union[Tuple[int, List[str], str, List[str]], Tuple[None, List[Any], None, List[Any]], Tuple[int, List[str], str, List[Any]]]: ... + def get_traceback_data(self) -> Dict[str, Any]: ... + def get_traceback_frames(self) -> List[Any]: ... + def get_traceback_html(self) -> SafeText: ... + def get_traceback_text(self) -> SafeText: ... + + +class SafeExceptionReporterFilter: + def cleanse_special_types(self, request: Optional[WSGIRequest], value: Any) -> Any: ... + def get_cleansed_multivaluedict( + self, + request: WSGIRequest, + multivaluedict: QueryDict + ) -> QueryDict: ... + def get_post_parameters( + self, + request: Optional[WSGIRequest] + ) -> QueryDict: ... + def is_active(self, request: Optional[WSGIRequest]) -> bool: ... \ No newline at end of file diff --git a/django/views/decorators/cache.pyi b/django/views/decorators/cache.pyi new file mode 100644 index 0000000..3ed1010 --- /dev/null +++ b/django/views/decorators/cache.pyi @@ -0,0 +1,10 @@ +from typing import ( + Callable, + Union, +) + + +def cache_page(timeout: Union[float, int], *, cache = ..., key_prefix = ...) -> Callable: ... + + +def never_cache(view_func: Callable) -> Callable: ... \ No newline at end of file diff --git a/django/views/decorators/csrf.pyi b/django/views/decorators/csrf.pyi new file mode 100644 index 0000000..c576150 --- /dev/null +++ b/django/views/decorators/csrf.pyi @@ -0,0 +1,26 @@ +from csrf_tests.tests import TestingHttpRequest +from django.http.request import HttpRequest +from typing import ( + Any, + Callable, + Dict, + Tuple, +) + + +def csrf_exempt(view_func: Callable) -> Callable: ... + + +class _EnsureCsrfCookie: + def _reject(self, request: TestingHttpRequest, reason: str) -> None: ... + def process_view( + self, + request: TestingHttpRequest, + callback: Callable, + callback_args: Tuple, + callback_kwargs: Dict[Any, Any] + ) -> None: ... + + +class _EnsureCsrfToken: + def _reject(self, request: HttpRequest, reason: str) -> None: ... \ No newline at end of file diff --git a/django/views/decorators/debug.pyi b/django/views/decorators/debug.pyi new file mode 100644 index 0000000..6981418 --- /dev/null +++ b/django/views/decorators/debug.pyi @@ -0,0 +1,7 @@ +from typing import Callable + + +def sensitive_post_parameters(*parameters) -> Callable: ... + + +def sensitive_variables(*variables) -> Callable: ... \ No newline at end of file diff --git a/django/views/decorators/http.pyi b/django/views/decorators/http.pyi new file mode 100644 index 0000000..0787384 --- /dev/null +++ b/django/views/decorators/http.pyi @@ -0,0 +1,13 @@ +from typing import ( + Callable, + List, +) + + +def condition(etag_func: Callable = ..., last_modified_func: None = ...) -> Callable: ... + + +def etag(etag_func: Callable) -> Callable: ... + + +def require_http_methods(request_method_list: List[str]) -> Callable: ... \ No newline at end of file diff --git a/django/views/decorators/vary.pyi b/django/views/decorators/vary.pyi new file mode 100644 index 0000000..6124a48 --- /dev/null +++ b/django/views/decorators/vary.pyi @@ -0,0 +1,7 @@ +from typing import Callable + + +def vary_on_cookie(func: Callable) -> Callable: ... + + +def vary_on_headers(*headers) -> Callable: ... \ No newline at end of file diff --git a/django/views/defaults.pyi b/django/views/defaults.pyi new file mode 100644 index 0000000..480a33f --- /dev/null +++ b/django/views/defaults.pyi @@ -0,0 +1,40 @@ +from django.core.exceptions import ( + PermissionDenied, + SuspiciousOperation, +) +from django.core.handlers.wsgi import WSGIRequest +from django.http.response import ( + Http404, + HttpResponseBadRequest, + HttpResponseForbidden, + HttpResponseNotFound, + HttpResponseServerError, +) +from typing import Optional + + +def bad_request( + request: WSGIRequest, + exception: SuspiciousOperation, + template_name: str = ... +) -> HttpResponseBadRequest: ... + + +def page_not_found( + request: WSGIRequest, + exception: Optional[Http404], + template_name: str = ... +) -> HttpResponseNotFound: ... + + +def permission_denied( + request: WSGIRequest, + exception: PermissionDenied, + template_name: str = ... +) -> HttpResponseForbidden: ... + + +def server_error( + request: WSGIRequest, + template_name: str = ... +) -> HttpResponseServerError: ... \ No newline at end of file diff --git a/django/views/generic/base.pyi b/django/views/generic/base.pyi new file mode 100644 index 0000000..60d696f --- /dev/null +++ b/django/views/generic/base.pyi @@ -0,0 +1,78 @@ +from django.core.handlers.wsgi import WSGIRequest +from django.http.response import ( + HttpResponse, + HttpResponseNotAllowed, + HttpResponseRedirect, + HttpResponseRedirectBase, +) +from django.template.response import TemplateResponse +from typing import ( + Any, + Callable, + Dict, + List, + Union, +) + + +class ContextMixin: + def get_context_data(self, **kwargs) -> Dict[str, Any]: ... + + +class RedirectView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> HttpResponseRedirectBase: ... + def get_redirect_url(self, *args, **kwargs) -> str: ... + def options( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> HttpResponseRedirect: ... + def post( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> HttpResponseRedirect: ... + + +class TemplateResponseMixin: + def get_template_names(self) -> List[str]: ... + def render_to_response( + self, + context: Dict[str, Any], + **response_kwargs + ) -> TemplateResponse: ... + + +class TemplateView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> TemplateResponse: ... + + +class View: + def __init__(self, **kwargs) -> None: ... + def _allowed_methods(self) -> List[str]: ... + @classmethod + def as_view(cls, **initkwargs) -> Callable: ... + def dispatch( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> Union[View, HttpResponse]: ... + def http_method_not_allowed( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> HttpResponseNotAllowed: ... \ No newline at end of file diff --git a/django/views/generic/dates.pyi b/django/views/generic/dates.pyi new file mode 100644 index 0000000..cfff596 --- /dev/null +++ b/django/views/generic/dates.pyi @@ -0,0 +1,138 @@ +from datetime import date +from django.core.handlers.wsgi import WSGIRequest +from django.db.models.base import Model +from django.db.models.query import QuerySet +from django.template.response import TemplateResponse +from django.views.generic.list import MultipleObjectTemplateResponseMixin +from typing import ( + Any, + Dict, + Optional, + Tuple, + Union, +) + + +def _date_from_string( + year: int, + year_format: str, + month: str = ..., + month_format: str = ..., + day: Union[str, int] = ..., + day_format: str = ..., + delim: str = ... +) -> date: ... + + +def _get_next_prev( + generic_view: MultipleObjectTemplateResponseMixin, + date: date, + is_previous: bool, + period: str +) -> Optional[date]: ... + + +def timezone_today() -> date: ... + + +class BaseArchiveIndexView: + def get_dated_items(self) -> Tuple[QuerySet, QuerySet, Dict[Any, Any]]: ... + + +class BaseDateDetailView: + def get_object(self, queryset: Optional[QuerySet] = ...) -> Model: ... + + +class BaseDateListView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> TemplateResponse: ... + def get_date_list( + self, + queryset: QuerySet, + date_type: None = ..., + ordering: str = ... + ) -> QuerySet: ... + def get_date_list_period(self) -> str: ... + def get_dated_queryset(self, **lookup) -> QuerySet: ... + def get_ordering(self) -> Union[str, Tuple[str, str]]: ... + + +class BaseDayArchiveView: + def _get_dated_items( + self, + date: date + ) -> Union[Tuple[None, QuerySet, Dict[str, Union[date, None]]], Tuple[None, QuerySet, Dict[str, date]]]: ... + def get_dated_items( + self + ) -> Union[Tuple[None, QuerySet, Dict[str, Union[date, None]]], Tuple[None, QuerySet, Dict[str, date]]]: ... + + +class BaseMonthArchiveView: + def get_dated_items( + self + ) -> Union[Tuple[QuerySet, QuerySet, Dict[str, Union[date, None]]], Tuple[QuerySet, QuerySet, Dict[str, date]]]: ... + + +class BaseTodayArchiveView: + def get_dated_items(self): ... + + +class BaseWeekArchiveView: + def get_dated_items(self) -> Tuple[None, QuerySet, Dict[str, date]]: ... + + +class BaseYearArchiveView: + def get_dated_items( + self + ) -> Union[Tuple[QuerySet, QuerySet, Dict[str, Union[date, None]]], Tuple[QuerySet, QuerySet, Dict[str, date]]]: ... + def get_make_object_list(self) -> bool: ... + + +class DateMixin: + def _make_date_lookup_arg(self, value: date) -> date: ... + def _make_single_date_lookup(self, date: date) -> Dict[str, date]: ... + def get_allow_future(self) -> bool: ... + def get_date_field(self) -> str: ... + @cached_property + def uses_datetime_field(self) -> bool: ... + + +class DayMixin: + def _get_current_day(self, date: date) -> date: ... + def _get_next_day(self, date: date) -> date: ... + def get_day(self) -> int: ... + def get_day_format(self) -> str: ... + def get_next_day(self, date: date) -> None: ... + def get_previous_day(self, date: date) -> date: ... + + +class MonthMixin: + def _get_current_month(self, date: date) -> date: ... + def _get_next_month(self, date: date) -> date: ... + def get_month(self) -> Union[str, int]: ... + def get_month_format(self) -> str: ... + def get_next_month(self, date: date) -> Optional[date]: ... + def get_previous_month(self, date: date) -> Optional[date]: ... + + +class WeekMixin: + def _get_current_week(self, date: date) -> date: ... + def _get_next_week(self, date: date) -> date: ... + def _get_weekday(self, date: date) -> int: ... + def get_next_week(self, date: date) -> Optional[date]: ... + def get_previous_week(self, date: date) -> Optional[date]: ... + def get_week(self) -> int: ... + def get_week_format(self) -> str: ... + + +class YearMixin: + def _get_current_year(self, date: date) -> date: ... + def _get_next_year(self, date: date) -> date: ... + def get_next_year(self, date: date) -> Optional[date]: ... + def get_previous_year(self, date: date) -> Optional[date]: ... + def get_year(self) -> int: ... + def get_year_format(self) -> str: ... \ No newline at end of file diff --git a/django/views/generic/detail.pyi b/django/views/generic/detail.pyi new file mode 100644 index 0000000..df94752 --- /dev/null +++ b/django/views/generic/detail.pyi @@ -0,0 +1,32 @@ +from django.core.handlers.wsgi import WSGIRequest +from django.db.models.base import Model +from django.db.models.query import QuerySet +from django.template.response import TemplateResponse +from typing import ( + Any, + Dict, + List, + Optional, + Union, +) + + +class BaseDetailView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> TemplateResponse: ... + + +class SingleObjectMixin: + def get_context_data(self, **kwargs) -> Dict[str, Any]: ... + def get_context_object_name(self, obj: Union[Model, Dict[str, str]]) -> Optional[str]: ... + def get_object(self, queryset: Optional[QuerySet] = ...) -> Model: ... + def get_queryset(self) -> QuerySet: ... + def get_slug_field(self) -> str: ... + + +class SingleObjectTemplateResponseMixin: + def get_template_names(self) -> List[str]: ... \ No newline at end of file diff --git a/django/views/generic/edit.pyi b/django/views/generic/edit.pyi new file mode 100644 index 0000000..6f82ed3 --- /dev/null +++ b/django/views/generic/edit.pyi @@ -0,0 +1,86 @@ +from django.core.handlers.wsgi import WSGIRequest +from django.db.models.base import Model +from django.forms.forms import ( + BaseForm, + Form, +) +from django.forms.models import ModelForm +from django.http.response import HttpResponseRedirect +from django.template.response import TemplateResponse +from django.utils.datastructures import MultiValueDict +from typing import ( + Any, + Dict, + Optional, + Type, + Union, +) + + +class BaseCreateView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> TemplateResponse: ... + + +class BaseUpdateView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> TemplateResponse: ... + + +class DeletionMixin: + def delete( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> HttpResponseRedirect: ... + def get_success_url(self) -> str: ... + def post( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> HttpResponseRedirect: ... + + +class FormMixin: + def form_invalid(self, form: Form) -> TemplateResponse: ... + def form_valid(self, form: Form) -> HttpResponseRedirect: ... + def get_context_data(self, **kwargs) -> Dict[str, Any]: ... + def get_form(self, form_class: None = ...) -> BaseForm: ... + def get_form_class(self) -> Any: ... + def get_form_kwargs(self) -> Dict[str, Union[None, MultiValueDict]]: ... + def get_initial(self) -> Dict[Any, Any]: ... + def get_prefix(self) -> None: ... + def get_success_url(self) -> str: ... + + +class ModelFormMixin: + def get_form_class(self) -> Type[ModelForm]: ... + def get_form_kwargs( + self + ) -> Dict[str, Union[None, MultiValueDict, Model]]: ... + def get_success_url(self) -> str: ... + + +class ProcessFormView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> TemplateResponse: ... + def post( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... \ No newline at end of file diff --git a/django/views/generic/list.pyi b/django/views/generic/list.pyi new file mode 100644 index 0000000..7276107 --- /dev/null +++ b/django/views/generic/list.pyi @@ -0,0 +1,54 @@ +from django.core.handlers.wsgi import WSGIRequest +from django.core.paginator import ( + Page, + Paginator, +) +from django.db.models.query import QuerySet +from django.template.response import TemplateResponse +from typing import ( + Any, + Dict, + List, + Optional, + Tuple, + Union, +) + + +class BaseListView: + def get( + self, + request: WSGIRequest, + *args, + **kwargs + ) -> TemplateResponse: ... + + +class MultipleObjectMixin: + def get_allow_empty(self) -> bool: ... + def get_context_data(self, *, object_list = ..., **kwargs) -> Dict[str, Any]: ... + def get_context_object_name( + self, + object_list: Optional[Union[QuerySet, List[Dict[str, str]]]] + ) -> Optional[str]: ... + def get_ordering(self) -> None: ... + def get_paginate_by(self, queryset: Union[QuerySet, List[Dict[str, str]]]) -> Optional[int]: ... + def get_paginate_orphans(self) -> int: ... + def get_paginator( + self, + queryset: QuerySet, + per_page: int, + orphans: int = ..., + allow_empty_first_page: bool = ..., + **kwargs + ) -> Paginator: ... + def get_queryset(self) -> Union[QuerySet, List[Dict[str, str]]]: ... + def paginate_queryset( + self, + queryset: QuerySet, + page_size: int + ) -> Tuple[Paginator, Page, QuerySet, bool]: ... + + +class MultipleObjectTemplateResponseMixin: + def get_template_names(self) -> List[str]: ... \ No newline at end of file diff --git a/django/views/i18n.pyi b/django/views/i18n.pyi new file mode 100644 index 0000000..46a676e --- /dev/null +++ b/django/views/i18n.pyi @@ -0,0 +1,44 @@ +from django.core.handlers.wsgi import WSGIRequest +from django.http.response import ( + HttpResponse, + HttpResponseRedirect, + JsonResponse, +) +from typing import ( + Any, + Dict, + List, + Optional, + Union, +) + + +def get_formats() -> Dict[str, Union[str, int, List[str]]]: ... + + +def set_language(request: WSGIRequest) -> HttpResponseRedirect: ... + + +class JSONCatalog: + def render_to_response( + self, + context: Dict[str, Union[Dict[str, Union[str, List[str]]], Dict[str, Union[str, int, List[str]]], str]], + **response_kwargs + ) -> JsonResponse: ... + + +class JavaScriptCatalog: + @property + def _num_plurals(self) -> int: ... + @property + def _plural_string(self) -> Optional[str]: ... + def get(self, request: WSGIRequest, *args, **kwargs) -> HttpResponse: ... + def get_catalog(self) -> Dict[str, Union[str, List[str]]]: ... + def get_context_data(self, **kwargs) -> Dict[str, Any]: ... + def get_paths(self, packages: List[str]) -> List[str]: ... + def get_plural(self) -> Optional[str]: ... + def render_to_response( + self, + context: Dict[str, Union[Dict[str, Union[str, int, List[str]]], None, Dict[str, str], Dict[str, Union[str, List[str]]]]], + **response_kwargs + ) -> HttpResponse: ... \ No newline at end of file diff --git a/django/views/static.pyi b/django/views/static.pyi new file mode 100644 index 0000000..bde093b --- /dev/null +++ b/django/views/static.pyi @@ -0,0 +1,24 @@ +from django.core.handlers.wsgi import WSGIRequest +from django.http.response import ( + FileResponse, + HttpResponse, +) +from pathlib import PosixPath +from typing import ( + Optional, + Union, +) + + +def directory_index(path: str, fullpath: PosixPath) -> HttpResponse: ... + + +def serve( + request: WSGIRequest, + path: str, + document_root: str = ..., + show_indexes: bool = ... +) -> Union[HttpResponse, FileResponse]: ... + + +def was_modified_since(header: Optional[str] = ..., mtime: float = ..., size: int = ...) -> bool: ... \ No newline at end of file