From 9a6826325716434d0c97ac36c99994f32a9464fb Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Tue, 13 Nov 2018 21:10:56 +0300 Subject: [PATCH] integrate more stubs --- django-stubs-generated/urls/resolvers.pyi | 19 +-- django-stubs/db/__init__.pyi | 2 + django-stubs/db/models/__init__.pyi | 4 +- django-stubs/db/models/expressions.pyi | 4 + django-stubs/db/models/fields/__init__.pyi | 4 + django-stubs/db/transaction.pyi | 34 ++++ django-stubs/db/utils.pyi | 33 ++++ django-stubs/http/__init__.pyi | 39 +++-- django-stubs/http/cookie.pyi | 7 +- django-stubs/http/multipartparser.pyi | 91 +++++++++++ django-stubs/urls/__init__.pyi | 9 +- django-stubs/urls/base.pyi | 33 ++++ django-stubs/urls/conf.pyi | 23 +++ django-stubs/urls/converters.pyi | 35 +++++ django-stubs/urls/exceptions.pyi | 9 ++ django-stubs/urls/resolvers.pyi | 175 ++++++++++++++------- django-stubs/urls/utils.pyi | 7 +- 17 files changed, 419 insertions(+), 109 deletions(-) create mode 100644 django-stubs/db/transaction.pyi create mode 100644 django-stubs/db/utils.pyi create mode 100644 django-stubs/http/multipartparser.pyi create mode 100644 django-stubs/urls/base.pyi create mode 100644 django-stubs/urls/conf.pyi create mode 100644 django-stubs/urls/converters.pyi create mode 100644 django-stubs/urls/exceptions.pyi diff --git a/django-stubs-generated/urls/resolvers.pyi b/django-stubs-generated/urls/resolvers.pyi index 53fc350..7e1f9eb 100644 --- a/django-stubs-generated/urls/resolvers.pyi +++ b/django-stubs-generated/urls/resolvers.pyi @@ -4,12 +4,9 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from django.contrib.flatpages.sitemaps import FlatPageSitemap from django.contrib.sitemaps import Sitemap from django.core.checks.messages import CheckMessage, Warning +from django.urls.converters import UUIDConverter from django.utils.datastructures import MultiValueDict -from .converters import get_converter -from .exceptions import NoReverseMatch, Resolver404 -from .utils import get_callable - class ResolverMatch: func: Callable = ... @@ -30,17 +27,7 @@ class ResolverMatch: app_names: Optional[List[Optional[str]]] = ..., namespaces: Optional[List[Optional[str]]] = ..., ) -> None: ... - def __getitem__( - self, index: int - ) -> Union[ - Callable, - Dict[str, Dict[str, Type[FlatPageSitemap]]], - Dict[str, Dict[str, Sitemap]], - Dict[str, OrderedDict], - Dict[str, int], - Dict[str, str], - Tuple, - ]: ... + def __getitem__(self, index: int) -> Any: ... def get_resolver( urlconf: Optional[Union[Type[Any], str]] = ... @@ -74,7 +61,7 @@ class RegexPattern(CheckURLMixin): class RoutePattern(CheckURLMixin): regex: Any = ... name: Optional[str] = ... - converters: Dict[str, django.urls.converters.UUIDConverter] = ... + converters: Dict[str, UUIDConverter] = ... def __init__( self, route: str, name: Optional[str] = ..., is_endpoint: bool = ... ) -> None: ... diff --git a/django-stubs/db/__init__.pyi b/django-stubs/db/__init__.pyi index e69de29..75807c9 100644 --- a/django-stubs/db/__init__.pyi +++ b/django-stubs/db/__init__.pyi @@ -0,0 +1,2 @@ +from .utils import (ProgrammingError as ProgrammingError, + IntegrityError as IntegrityError) \ No newline at end of file diff --git a/django-stubs/db/models/__init__.pyi b/django-stubs/db/models/__init__.pyi index c099d9b..6e5899a 100644 --- a/django-stubs/db/models/__init__.pyi +++ b/django-stubs/db/models/__init__.pyi @@ -21,4 +21,6 @@ from .query import (QuerySet as QuerySet, from .query_utils import Q as Q -from .lookups import (Lookup as Lookup) +from .lookups import Lookup as Lookup + +from .expressions import F as F diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index 7ec57c3..3b9c362 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -177,3 +177,7 @@ class CombinedExpression(SQLiteNumericMixin, Expression): summarize: bool = ..., for_save: bool = ..., ) -> CombinedExpression: ... + + +class F(Combinable): + def __init__(self, name: str): ... \ No newline at end of file diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index f7a0dac..42374ff 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -35,3 +35,7 @@ class SlugField(CharField): class TextField(Field): def __get__(self, instance, owner) -> str: ... + + +class BooleanField(Field): + def __get__(self, instance, owner) -> bool: ... diff --git a/django-stubs/db/transaction.pyi b/django-stubs/db/transaction.pyi new file mode 100644 index 0000000..ce94950 --- /dev/null +++ b/django-stubs/db/transaction.pyi @@ -0,0 +1,34 @@ +from contextlib import ContextDecorator +from typing import Any, Callable, Optional, Union, ContextManager + +from django.db import ProgrammingError + + +class TransactionManagementError(ProgrammingError): ... + +def get_connection(using: Optional[str] = ...) -> Any: ... +def get_autocommit(using: Optional[str] = ...) -> bool: ... +def set_autocommit(autocommit: bool, using: None = ...) -> Any: ... +def commit(using: None = ...) -> Any: ... +def rollback(using: None = ...) -> Any: ... +def savepoint(using: None = ...) -> str: ... +def savepoint_rollback(sid: str, using: None = ...) -> None: ... +def savepoint_commit(sid: Any, using: Optional[Any] = ...) -> None: ... +def clean_savepoints(using: Optional[Any] = ...) -> None: ... +def get_rollback(using: None = ...) -> bool: ... +def set_rollback(rollback: bool, using: Optional[str] = ...) -> None: ... +def on_commit(func: Callable, using: None = ...) -> None: ... + +class Atomic(ContextDecorator): + using: Optional[str] = ... + savepoint: bool = ... + def __init__(self, using: Optional[str], savepoint: bool) -> None: ... + def __enter__(self) -> None: ... + def __exit__( + self, exc_type: None, exc_value: None, traceback: None + ) -> None: ... + +def atomic( + using: Optional[Union[Callable, str]] = ..., savepoint: bool = ... +) -> ContextManager[Atomic]: ... +def non_atomic_requests(using: Callable = ...) -> Callable: ... diff --git a/django-stubs/db/utils.pyi b/django-stubs/db/utils.pyi new file mode 100644 index 0000000..230ce4e --- /dev/null +++ b/django-stubs/db/utils.pyi @@ -0,0 +1,33 @@ +from typing import Any, Dict, List, Optional + + +DEFAULT_DB_ALIAS: str +DJANGO_VERSION_PICKLE_KEY: str + +class Error(Exception): ... +class InterfaceError(Error): ... +class DatabaseError(Error): ... +class DataError(DatabaseError): ... +class OperationalError(DatabaseError): ... +class IntegrityError(DatabaseError): ... +class InternalError(DatabaseError): ... +class ProgrammingError(DatabaseError): ... +class NotSupportedError(DatabaseError): ... + +def load_backend(backend_name: str) -> Any: ... + +class ConnectionDoesNotExist(Exception): ... + +class ConnectionHandler: + databases: Dict[str, Dict[str, Optional[Any]]] + def __init__( + self, databases: Dict[str, Dict[str, Optional[Any]]] = ... + ) -> None: ... + def ensure_defaults(self, alias: str) -> None: ... + def prepare_test_settings(self, alias: str) -> None: ... + def __getitem__(self, alias: str) -> Any: ... + def __setitem__(self, key: Any, value: Any) -> None: ... + def __delitem__(self, key: Any) -> None: ... + def __iter__(self): ... + def all(self) -> List[Any]: ... + def close_all(self) -> None: ... diff --git a/django-stubs/http/__init__.pyi b/django-stubs/http/__init__.pyi index 491239b..91b892f 100644 --- a/django-stubs/http/__init__.pyi +++ b/django-stubs/http/__init__.pyi @@ -1,21 +1,20 @@ -from django.http.cookie import SimpleCookie, parse_cookie -from django.http.request import ( - HttpRequest, QueryDict, RawPostDataException, UnreadablePostError, -) -from django.http.response import ( - BadHeaderError, FileResponse, Http404, HttpResponse, - HttpResponseBadRequest, HttpResponseForbidden, HttpResponseGone, - HttpResponseNotAllowed, HttpResponseNotFound, HttpResponseNotModified, - HttpResponsePermanentRedirect, HttpResponseRedirect, - HttpResponseServerError, JsonResponse, StreamingHttpResponse, -) +from .request import (HttpRequest as HttpRequest) -__all__ = [ - 'SimpleCookie', 'parse_cookie', 'HttpRequest', 'QueryDict', - 'RawPostDataException', 'UnreadablePostError', - 'HttpResponse', 'StreamingHttpResponse', 'HttpResponseRedirect', - 'HttpResponsePermanentRedirect', 'HttpResponseNotModified', - 'HttpResponseBadRequest', 'HttpResponseForbidden', 'HttpResponseNotFound', - 'HttpResponseNotAllowed', 'HttpResponseGone', 'HttpResponseServerError', - 'Http404', 'BadHeaderError', 'JsonResponse', 'FileResponse', -] +from .response import (BadHeaderError as BadHeaderError, + FileResponse as FileResponse, + Http404 as Http404, + HttpResponse as HttpResponse, + HttpResponseBadRequest as HttpResponseBadRequest, + HttpResponseForbidden as HttpResponseForbidden, + HttpResponseGone as HttpResponseGone, + HttpResponseNotAllowed as HttpResponseNotAllowed, + HttpResponseNotFound as HttpResponseNotFound, + HttpResponseNotModified as HttpResponseNotModified, + HttpResponsePermanentRedirect as HttpResponsePermanentRedirect, + HttpResponseRedirect as HttpResponseRedirect, + HttpResponseServerError as HttpResponseServerError, + JsonResponse as JsonResponse, + StreamingHttpResponse as StreamingHttpResponse) + +from .cookie import (SimpleCookie as SimpleCookie, + parse_cookie as parse_cookie) diff --git a/django-stubs/http/cookie.pyi b/django-stubs/http/cookie.pyi index 4d6f502..e2dc91d 100644 --- a/django-stubs/http/cookie.pyi +++ b/django-stubs/http/cookie.pyi @@ -1,8 +1,5 @@ -# Stubs for django.http.cookie (Python 3.5) +from typing import Any, Dict -from typing import Dict -from http.cookies import SimpleCookie, Morsel - -cookie_pickles_properly = ... # type: bool +SimpleCookie: Any def parse_cookie(cookie: str) -> Dict[str, str]: ... diff --git a/django-stubs/http/multipartparser.pyi b/django-stubs/http/multipartparser.pyi new file mode 100644 index 0000000..e8eded1 --- /dev/null +++ b/django-stubs/http/multipartparser.pyi @@ -0,0 +1,91 @@ +from io import BytesIO +from typing import Any, Dict, Iterator, List, Optional, Tuple, Union + +from django.http.request import QueryDict +from django.utils.datastructures import ImmutableList, MultiValueDict + + +class MultiPartParserError(Exception): ... + + +class InputStreamExhausted(Exception): ... + + +class MultiPartParser: + def __init__( + self, + META: Dict[str, Any], + input_data: BytesIO, + upload_handlers: Union[List[Any], ImmutableList], + encoding: Optional[str] = ..., + ) -> None: ... + + def parse(self) -> Tuple[QueryDict, MultiValueDict]: ... + + def handle_file_complete( + self, old_field_name: str, counters: List[int] + ) -> None: ... + + def IE_sanitize(self, filename: str) -> str: ... + + +class LazyStream: + length: None = ... + position: int = ... + + def __init__( + self, producer: Union[BoundaryIter, ChunkIter], length: None = ... + ) -> None: ... + + def tell(self): ... + + def read(self, size: Optional[int] = ...) -> bytes: ... + + def __next__(self) -> bytes: ... + + def close(self) -> None: ... + + def __iter__(self) -> LazyStream: ... + + def unget(self, bytes: bytes) -> None: ... + + +class ChunkIter: + flo: BytesIO = ... + chunk_size: int = ... + + def __init__( + self, flo: BytesIO, chunk_size: int = ... + ) -> None: ... + + def __next__(self) -> bytes: ... + + def __iter__(self): ... + + +class InterBoundaryIter: + def __init__(self, stream: LazyStream, boundary: bytes) -> None: ... + + def __iter__(self) -> InterBoundaryIter: ... + + def __next__(self) -> LazyStream: ... + + +class BoundaryIter: + def __init__(self, stream: LazyStream, boundary: bytes) -> None: ... + + def __iter__(self): ... + + def __next__(self) -> bytes: ... + + +class Parser: + def __init__(self, stream: LazyStream, boundary: bytes) -> None: ... + + def __iter__( + self + ) -> Iterator[ + Tuple[ + str, Dict[str, Tuple[str, Dict[str, Union[bytes, str]]]], LazyStream + ] + ]: ... diff --git a/django-stubs/urls/__init__.pyi b/django-stubs/urls/__init__.pyi index 5ee591b..ad3cdb9 100644 --- a/django-stubs/urls/__init__.pyi +++ b/django-stubs/urls/__init__.pyi @@ -1,9 +1,8 @@ -from .base import ( # type: ignore # stub not done yet - clear_script_prefix, clear_url_caches, get_script_prefix, get_urlconf, - is_valid_path, resolve, reverse, reverse_lazy, set_script_prefix, - set_urlconf, translate_url, +from .conf import ( + include as include, + path as path, + re_path as re_path ) -from .exceptions import NoReverseMatch, Resolver404 # type: ignore # stub not done yet from .resolvers import ( LocaleRegexProvider, LocaleRegexURLResolver, RegexURLPattern, RegexURLResolver, ResolverMatch, get_ns_resolver, get_resolver, diff --git a/django-stubs/urls/base.pyi b/django-stubs/urls/base.pyi new file mode 100644 index 0000000..b1dc0b7 --- /dev/null +++ b/django-stubs/urls/base.pyi @@ -0,0 +1,33 @@ +from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union +from uuid import UUID + +from django.urls.resolvers import ResolverMatch + +from .exceptions import NoReverseMatch, Resolver404 +from .resolvers import get_ns_resolver, get_resolver +from .utils import get_callable + + +def resolve(path: str, urlconf: Optional[str] = ...) -> ResolverMatch: ... +def reverse( + viewname: Optional[Union[Callable, str]], + urlconf: Optional[str] = ..., + args: Optional[Union[List[UUID], Tuple]] = ..., + kwargs: Optional[ + Union[ + Dict[str, None], Dict[str, bytes], Dict[str, str], Dict[str, UUID] + ] + ] = ..., + current_app: Optional[str] = ..., +) -> str: ... + +reverse_lazy: Any + +def clear_url_caches() -> None: ... +def set_script_prefix(prefix: str) -> None: ... +def get_script_prefix() -> str: ... +def clear_script_prefix() -> None: ... +def set_urlconf(urlconf_name: Optional[Union[Type[Any], str]]) -> None: ... +def get_urlconf(default: None = ...) -> Optional[Union[Type[Any], str]]: ... +def is_valid_path(path: str, urlconf: Optional[str] = ...) -> bool: ... +def translate_url(url: str, lang_code: str) -> str: ... diff --git a/django-stubs/urls/conf.pyi b/django-stubs/urls/conf.pyi new file mode 100644 index 0000000..d757196 --- /dev/null +++ b/django-stubs/urls/conf.pyi @@ -0,0 +1,23 @@ +from typing import Any, Callable, List, Optional, Tuple, Union + +from django.urls.resolvers import URLPattern, URLResolver + +from .resolvers import (LocalePrefixPattern, RegexPattern, RoutePattern, + URLPattern, URLResolver) + + +def include( + arg: Union[ + List[Tuple[str, Callable]], + List[URLPattern], + List[URLResolver], + Tuple[List[URLResolver], str], + str, + ], + namespace: Optional[str] = ..., +) -> Union[ + Tuple[List[Any], str, str], Tuple[List[URLResolver], None, None] +]: ... + +path: Any +re_path: Any diff --git a/django-stubs/urls/converters.pyi b/django-stubs/urls/converters.pyi new file mode 100644 index 0000000..80d00d5 --- /dev/null +++ b/django-stubs/urls/converters.pyi @@ -0,0 +1,35 @@ +from typing import Any, Dict, Type, Union +from uuid import UUID + + +class IntConverter: + regex: str = ... + def to_python(self, value: str) -> int: ... + def to_url(self, value: Union[int, str]) -> str: ... + +class StringConverter: + regex: str = ... + def to_python(self, value: str) -> str: ... + def to_url(self, value: Union[int, str, UUID]) -> Union[int, str, UUID]: ... + +class UUIDConverter: + regex: str = ... + def to_python(self, value: str) -> UUID: ... + def to_url(self, value: Union[str, UUID]) -> str: ... + +class SlugConverter(StringConverter): + regex: str = ... + +class PathConverter(StringConverter): + regex: str = ... + +DEFAULT_CONVERTERS: Any +REGISTERED_CONVERTERS: Any + +def register_converter(converter: Type[Any], type_name: str) -> None: ... +def get_converters() -> Dict[ + str, Union[IntConverter, StringConverter, UUIDConverter] +]: ... +def get_converter( + raw_converter: str +) -> Union[IntConverter, StringConverter, UUIDConverter]: ... diff --git a/django-stubs/urls/exceptions.pyi b/django-stubs/urls/exceptions.pyi new file mode 100644 index 0000000..87bf528 --- /dev/null +++ b/django-stubs/urls/exceptions.pyi @@ -0,0 +1,9 @@ +from django.http import Http404 + + +class Resolver404(Http404): + pass + + +class NoReverseMatch(Exception): + pass diff --git a/django-stubs/urls/resolvers.pyi b/django-stubs/urls/resolvers.pyi index 73cbee5..19e3837 100644 --- a/django-stubs/urls/resolvers.pyi +++ b/django-stubs/urls/resolvers.pyi @@ -1,75 +1,132 @@ -# Stubs for django.urls.resolvers (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union -from typing import Any, Callable, Dict, Iterable, List, Optional, Pattern, Tuple, Union - -from django.http.response import HttpResponse +from django.urls.converters import UUIDConverter from django.utils.datastructures import MultiValueDict -# Auxiliar types -URLPattern = Union['RegexURLResolver', 'RegexURLPattern'] -Params = Dict[str, object] # Arguments for views -# Auxiliar type for allowed resolver configurations -URLConf = Union[str, List[URLPattern]] - -# The result type for regex_helper.normalize() -NormalizedRegexForms = List[Tuple[str, List[str]]] -ReverseLookup = MultiValueDict[str, Tuple[NormalizedRegexForms, str, Params]] -Namespace = Dict[str, Tuple[str, 'RegexURLResolver']] -AppDict = Dict[str, List[str]] - -_View = Callable[..., HttpResponse] class ResolverMatch: - func = ... # type: Callable - args = ... # type: Iterable[object] - kwargs = ... # type: Params - url_name = ... # type: Optional[str] - app_names = ... # type: List[str] - app_name = ... # type: str - namespaces = ... # type: List[str] - namespace = ... # type: str - view_name = ... # type: str - def __init__(self, func: Callable, args: Iterable[object], kwargs: Params, url_name: str=None, app_names: Iterable[str]=None, namespaces: Iterable[str]=None) -> None: ... + func: Callable = ... + args: Tuple = ... + kwargs: Dict[str, Any] = ... + url_name: Optional[str] = ... + app_names: List[str] = ... + app_name: str = ... + namespaces: List[str] = ... + namespace: str = ... + view_name: str = ... + def __init__( + self, + func: Callable, + args: Tuple, + kwargs: Dict[str, Any], + url_name: Optional[str] = ..., + app_names: Optional[List[Optional[str]]] = ..., + namespaces: Optional[List[Optional[str]]] = ..., + ) -> None: ... def __getitem__(self, index: int) -> Any: ... -def get_resolver(urlconf: Optional[URLConf]=None) -> 'RegexURLResolver': ... -def get_ns_resolver(ns_pattern: str, resolver: 'RegexURLResolver') -> 'RegexURLResolver': ... +def get_resolver( + urlconf: Optional[Union[Type[Any], str]] = ... +) -> URLResolver: ... +def get_ns_resolver( + ns_pattern: str, resolver: URLResolver, converters: Tuple +) -> URLResolver: ... -class LocaleRegexProvider: - def __init__(self, regex: Optional[str]) -> None: ... +class LocaleRegexDescriptor: + attr: str = ... + def __init__(self, attr: Any) -> None: ... + def __get__( + self, instance: Optional[RegexPattern], cls: Type[RegexPattern] = ... + ) -> LocaleRegexDescriptor: ... + +class CheckURLMixin: + def describe(self) -> str: ... + +class RegexPattern(CheckURLMixin): + regex: Any = ... + name: Optional[str] = ... + converters: Dict[Any, Any] = ... + def __init__( + self, regex: str, name: Optional[str] = ..., is_endpoint: bool = ... + ) -> None: ... + def match( + self, path: str + ) -> Optional[Tuple[str, Tuple, Dict[str, str]]]: ... + def check(self) -> List[Warning]: ... + +class RoutePattern(CheckURLMixin): + regex: Any = ... + name: Optional[str] = ... + converters: Dict[str, UUIDConverter] = ... + def __init__( + self, route: str, name: Optional[str] = ..., is_endpoint: bool = ... + ) -> None: ... + def match( + self, path: str + ) -> Optional[Tuple[str, Tuple, Dict[str, Union[int, str]]]]: ... + def check(self) -> List[Warning]: ... + +class LocalePrefixPattern: + prefix_default_language: bool = ... + converters: Dict[Any, Any] = ... + def __init__(self, prefix_default_language: bool = ...) -> None: ... @property - def regex(self) -> Pattern[str]: ... + def regex(self): ... + @property + def language_prefix(self) -> str: ... + def match( + self, path: str + ) -> Optional[Tuple[str, Tuple, Dict[Any, Any]]]: ... + def check(self) -> List[Any]: ... + def describe(self) -> str: ... -class RegexURLPattern(LocaleRegexProvider): - callback = ... # type: _View - default_args = ... # type: Params - name = ... # type: Optional[str] - def __init__(self, regex: str, callback: _View, default_args: Params=None, name: str=None) -> None: ... +class URLPattern: + lookup_str: str + pattern: Any = ... + callback: Callable = ... + default_args: Optional[Dict[str, str]] = ... + name: Optional[str] = ... + def __init__( + self, + pattern: Any, + callback: Callable, + default_args: Optional[Dict[str, str]] = ..., + name: Optional[str] = ..., + ) -> None: ... + def check(self) -> List[Warning]: ... def resolve(self, path: str) -> Optional[ResolverMatch]: ... - def lookup_str(self) -> str: ... -class RegexURLResolver(LocaleRegexProvider): - urlconf_name = ... # type: URLConf - default_kwargs = ... # type: Params - namespace = ... # type: Optional[str] - app_name = ... # type: Optional[str] - def __init__(self, regex: Optional[str], urlconf_name: URLConf, default_kwargs: Params=None, app_name: str=None, namespace: str=None) -> None: ... +class URLResolver: + url_patterns: List[Tuple[str, Callable]] + urlconf_module: Optional[Union[List[Tuple[str, Callable]], Type[Any]]] + pattern: Any = ... + urlconf_name: Optional[str] = ... + callback: None = ... + default_kwargs: Dict[str, Union[Dict[Any, Any], str]] = ... + namespace: Optional[str] = ... + app_name: Optional[str] = ... + def __init__( + self, + pattern: Any, + urlconf_name: Optional[str], + default_kwargs: Optional[ + Union[Dict[str, Dict[Any, Any]], Dict[str, str]] + ] = ..., + app_name: Optional[str] = ..., + namespace: Optional[str] = ..., + ) -> None: ... @property - def reverse_dict(self) -> ReverseLookup: ... + def reverse_dict(self) -> MultiValueDict: ... @property - def namespace_dict(self) -> Namespace: ... + def namespace_dict(self) -> Dict[str, Tuple[str, URLResolver]]: ... @property - def app_dict(self) -> AppDict: ... + def app_dict(self) -> Dict[str, List[str]]: ... def resolve(self, path: str) -> ResolverMatch: ... - def urlconf_module(self) -> Union[Iterable[URLPattern], Any]: ... - def url_patterns(self) -> Iterable[URLPattern]: ... - def resolve_error_handler(self, view_type: int) -> Tuple[Callable, Params]: ... - def reverse(self, lookup_view: str, *args: object, **kwargs: object) -> str: ... - -class LocaleRegexURLResolver(RegexURLResolver): - prefix_default_language = ... # type: bool - def __init__(self, urlconf_name: URLConf, default_kwargs: Params=None, app_name: str=None, namespace: str=None, prefix_default_language: bool=True) -> None: ... - @property - def regex(self) -> Pattern[str]: ... + def urlconf_module( + self + ) -> Optional[Union[List[Tuple[str, Callable]], Type[Any]]]: ... + def url_patterns(self) -> List[Tuple[str, Callable]]: ... + def resolve_error_handler( + self, view_type: int + ) -> Tuple[Callable, Dict[Any, Any]]: ... + def reverse(self, lookup_view: str, *args: Any, **kwargs: Any) -> str: ... diff --git a/django-stubs/urls/utils.pyi b/django-stubs/urls/utils.pyi index c69dc13..3c9e2a1 100644 --- a/django-stubs/urls/utils.pyi +++ b/django-stubs/urls/utils.pyi @@ -1,6 +1,7 @@ -# Stubs for django.urls.utils (Python 3.5) - from typing import Callable, Tuple, Union -def get_callable(lookup_view: Union[str, Callable]) -> Callable: ... + +def get_callable(lookup_view: Union[Callable, str]) -> Callable: ... + + def get_mod_func(callback: str) -> Tuple[str, str]: ...