mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 16:27:09 +08:00
move django.urls completely
This commit is contained in:
@@ -1,26 +1,25 @@
|
||||
# Stubs for django.conf.urls (Python 3.5)
|
||||
|
||||
from types import ModuleType
|
||||
from typing import Any, Callable, Dict, List, Optional, overload, Tuple, Union
|
||||
|
||||
from django.http.response import HttpResponse
|
||||
from django.urls import RegexURLPattern, RegexURLResolver
|
||||
from django.urls.resolvers import URLConf
|
||||
from django.urls import URLResolver, URLPattern
|
||||
|
||||
handler400 = ... # type: str
|
||||
handler403 = ... # type: str
|
||||
handler404 = ... # type: str
|
||||
handler500 = ... # type: str
|
||||
|
||||
def include(arg: Any, namespace: str = None, app_name: str = None) -> Tuple[URLConf, Optional[str], Optional[str]]: ...
|
||||
URLConf = Union[str, ModuleType]
|
||||
|
||||
def include(arg: Any, namespace: str = ..., app_name: str = ...) -> Tuple[URLConf, Optional[str], Optional[str]]: ...
|
||||
@overload
|
||||
def url(
|
||||
regex: str, view: Callable[..., HttpResponse], kwargs: Dict[str, Any] = None, name: str = None
|
||||
) -> RegexURLPattern: ... # type: ignore # issue 253 of typing
|
||||
regex: str, view: Callable[..., HttpResponse], kwargs: Dict[str, Any] = ..., name: str = ...
|
||||
) -> URLPattern: ... # type: ignore # issue 253 of typing
|
||||
@overload
|
||||
def url(
|
||||
regex: str, view: Tuple[URLConf, Optional[str], Optional[str]], kwargs: Dict[str, Any] = None, name: str = None
|
||||
) -> RegexURLResolver: ...
|
||||
regex: str, view: Tuple[URLConf, Optional[str], Optional[str]], kwargs: Dict[str, Any] = ..., name: str = ...
|
||||
) -> URLResolver: ...
|
||||
@overload
|
||||
def url(
|
||||
regex: str, view: List[Union[URLConf, str]], kwargs: Dict[str, Any] = None, name: str = None
|
||||
) -> RegexURLResolver: ...
|
||||
def url(regex: str, view: List[Union[URLConf, str]], kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver: ...
|
||||
|
||||
@@ -8,7 +8,6 @@ from django.core.mail.message import EmailMultiAlternatives as EmailMultiAlterna
|
||||
from django.core.mail.message import SafeMIMEMultipart as SafeMIMEMultipart
|
||||
from django.core.mail.message import SafeMIMEText as SafeMIMEText
|
||||
from django.core.mail.message import forbid_multi_line_headers as forbid_multi_line_headers
|
||||
from django.core.mail.message import make_msgid as make_msgid
|
||||
from django.core.mail.utils import DNS_NAME as DNS_NAME
|
||||
from django.core.mail.utils import CachedDnsName as CachedDnsName
|
||||
|
||||
@@ -45,3 +44,5 @@ def mail_managers(
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
|
||||
outbox = [EmailMessage()]
|
||||
|
||||
@@ -1,8 +1,36 @@
|
||||
from .base import reverse as reverse
|
||||
# noinspection PyUnresolvedReferences
|
||||
from .base import (
|
||||
clear_script_prefix as clear_script_prefix,
|
||||
clear_url_caches as clear_url_caches,
|
||||
get_script_prefix as get_script_prefix,
|
||||
get_urlconf as get_urlconf,
|
||||
is_valid_path as is_valid_path,
|
||||
resolve as resolve,
|
||||
reverse as reverse,
|
||||
reverse_lazy as reverse_lazy,
|
||||
set_script_prefix as set_script_prefix,
|
||||
set_urlconf as set_urlconf,
|
||||
translate_url as translate_url,
|
||||
)
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from .conf import include as include, path as path, re_path as re_path
|
||||
|
||||
from .resolvers import ResolverMatch as ResolverMatch, get_ns_resolver as get_ns_resolver, get_resolver as get_resolver
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from .converters import register_converter as register_converter
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from .exceptions import NoReverseMatch as NoReverseMatch, Resolver404 as Resolver404
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from .resolvers import (
|
||||
LocalePrefixPattern as LocalePrefixPattern,
|
||||
ResolverMatch as ResolverMatch,
|
||||
URLPattern as URLPattern,
|
||||
URLResolver as URLResolver,
|
||||
get_ns_resolver as get_ns_resolver,
|
||||
get_resolver as get_resolver,
|
||||
)
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from .utils import get_callable as get_callable, get_mod_func as get_mod_func
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||
from uuid import UUID
|
||||
from typing import Any, Callable, Dict, Optional, Type, Union, Sequence
|
||||
|
||||
from django.urls.resolvers import ResolverMatch
|
||||
|
||||
@@ -7,8 +6,8 @@ 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]]] = ...,
|
||||
args: Optional[Sequence[Any]] = ...,
|
||||
kwargs: Optional[Dict[str, Any]] = ...,
|
||||
current_app: Optional[str] = ...,
|
||||
) -> str: ...
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from .resolvers import 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]]: ...
|
||||
) -> Tuple[List[URLResolver], Optional[str], Optional[str]]: ...
|
||||
|
||||
path: Any
|
||||
re_path: Any
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
from typing import Any, Dict, Type, Union
|
||||
from typing import Any, Dict, Type, Union, Protocol
|
||||
from uuid import UUID
|
||||
|
||||
class IntConverter:
|
||||
regex: str = ...
|
||||
def to_python(self, value: str) -> int: ...
|
||||
def to_url(self, value: Union[int, str]) -> str: ...
|
||||
def to_url(self, value: Union[str, int]) -> 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]: ...
|
||||
def to_url(self, value: str) -> str: ...
|
||||
|
||||
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 SlugConverter(StringConverter): ...
|
||||
class PathConverter(StringConverter): ...
|
||||
|
||||
class PathConverter(StringConverter):
|
||||
regex: str = ...
|
||||
|
||||
DEFAULT_CONVERTERS: Any
|
||||
REGISTERED_CONVERTERS: Any
|
||||
DEFAULT_CONVERTERS: Dict[str, Any]
|
||||
REGISTERED_CONVERTERS: Dict[str, 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]: ...
|
||||
def get_converters() -> Dict[str, Any]: ...
|
||||
def get_converter(raw_converter: str) -> Any: ...
|
||||
|
||||
@@ -24,7 +24,7 @@ class ResolverMatch:
|
||||
) -> None: ...
|
||||
def __getitem__(self, index: int) -> Any: ...
|
||||
|
||||
def get_resolver(urlconf: Optional[Union[Type[Any], str]] = ...) -> URLResolver: ...
|
||||
def get_resolver(urlconf: Optional[str] = ...) -> URLResolver: ...
|
||||
def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: Tuple) -> URLResolver: ...
|
||||
|
||||
class LocaleRegexDescriptor:
|
||||
@@ -59,7 +59,7 @@ class LocalePrefixPattern:
|
||||
def regex(self): ...
|
||||
@property
|
||||
def language_prefix(self) -> str: ...
|
||||
def match(self, path: str) -> Optional[Tuple[str, Tuple, Dict[Any, Any]]]: ...
|
||||
def match(self, path: str) -> Optional[Tuple[str, Tuple, Dict[str, Any]]]: ...
|
||||
def check(self) -> List[Any]: ...
|
||||
def describe(self) -> str: ...
|
||||
|
||||
@@ -77,18 +77,18 @@ class URLPattern:
|
||||
|
||||
class URLResolver:
|
||||
url_patterns: List[Tuple[str, Callable]]
|
||||
urlconf_module: Optional[Union[List[Tuple[str, Callable]], Type[Any]]]
|
||||
urlconf_module: Optional[List[Tuple[str, Callable]]]
|
||||
pattern: Any = ...
|
||||
urlconf_name: Optional[str] = ...
|
||||
callback: None = ...
|
||||
default_kwargs: Dict[str, Union[Dict[Any, Any], str]] = ...
|
||||
default_kwargs: Dict[str, Any] = ...
|
||||
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]]] = ...,
|
||||
default_kwargs: Optional[Dict[str, Any]] = ...,
|
||||
app_name: Optional[str] = ...,
|
||||
namespace: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
@@ -99,7 +99,7 @@ class URLResolver:
|
||||
@property
|
||||
def app_dict(self) -> Dict[str, List[str]]: ...
|
||||
def resolve(self, path: str) -> ResolverMatch: ...
|
||||
def urlconf_module(self) -> Optional[Union[List[Tuple[str, Callable]], Type[Any]]]: ...
|
||||
def urlconf_module(self) -> Optional[List[Tuple[str, Callable]]]: ...
|
||||
def url_patterns(self) -> List[Tuple[str, Callable]]: ...
|
||||
def resolve_error_handler(self, view_type: int) -> Tuple[Callable, Dict[Any, Any]]: ...
|
||||
def resolve_error_handler(self, view_type: int) -> Tuple[Callable, Dict[str, Any]]: ...
|
||||
def reverse(self, lookup_view: str, *args: Any, **kwargs: Any) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user