mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-21 19:32:16 +08:00
integrate stubs from mypy-django
This commit is contained in:
21
django-stubs/http/__init__.pyi
Normal file
21
django-stubs/http/__init__.pyi
Normal file
@@ -0,0 +1,21 @@
|
||||
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,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'SimpleCookie', 'parse_cookie', 'HttpRequest', 'QueryDict',
|
||||
'RawPostDataException', 'UnreadablePostError',
|
||||
'HttpResponse', 'StreamingHttpResponse', 'HttpResponseRedirect',
|
||||
'HttpResponsePermanentRedirect', 'HttpResponseNotModified',
|
||||
'HttpResponseBadRequest', 'HttpResponseForbidden', 'HttpResponseNotFound',
|
||||
'HttpResponseNotAllowed', 'HttpResponseGone', 'HttpResponseServerError',
|
||||
'Http404', 'BadHeaderError', 'JsonResponse', 'FileResponse',
|
||||
]
|
||||
8
django-stubs/http/cookie.pyi
Normal file
8
django-stubs/http/cookie.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
# Stubs for django.http.cookie (Python 3.5)
|
||||
|
||||
from typing import Dict
|
||||
from http.cookies import SimpleCookie, Morsel
|
||||
|
||||
cookie_pickles_properly = ... # type: bool
|
||||
|
||||
def parse_cookie(cookie: str) -> Dict[str, str]: ...
|
||||
80
django-stubs/http/request.pyi
Normal file
80
django-stubs/http/request.pyi
Normal file
@@ -0,0 +1,80 @@
|
||||
# Stubs for django.http.request (Python 3.5)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from typing import (Any, BinaryIO, Dict, Iterable, Iterator, List, Optional, overload, Pattern,
|
||||
Tuple, Union)
|
||||
|
||||
from django.core.files import uploadhandler, uploadedfile
|
||||
from django.utils.datastructures import MultiValueDict, ImmutableList
|
||||
from django.urls import ResolverMatch
|
||||
|
||||
RAISE_ERROR = ... # type: object
|
||||
host_validation_re = ... # type: Pattern
|
||||
|
||||
class UnreadablePostError(IOError): ...
|
||||
class RawPostDataException(Exception): ...
|
||||
|
||||
UploadHandlerList = Union[List[uploadhandler.FileUploadHandler],
|
||||
ImmutableList[uploadhandler.FileUploadHandler]]
|
||||
|
||||
class HttpRequest(BinaryIO):
|
||||
GET = ... # type: QueryDict
|
||||
POST = ... # type: QueryDict
|
||||
COOKIES = ... # type: Dict[str, str]
|
||||
META = ... # type: Dict[str, str]
|
||||
FILES = ... # type: MultiValueDict[str, uploadedfile.UploadedFile]
|
||||
path = ... # type: str
|
||||
path_info = ... # type: str
|
||||
method = ... # type: Optional[str]
|
||||
resolver_match = ... # type: ResolverMatch
|
||||
content_type = ... # type: Optional[str]
|
||||
content_params = ... # type: Optional[Dict[str, str]]
|
||||
def __init__(self) -> None: ...
|
||||
def get_host(self) -> str: ...
|
||||
def get_port(self) -> str: ...
|
||||
def get_full_path(self, force_append_slash: bool=False) -> str: ...
|
||||
def get_signed_cookie(self, key: str, default: str=..., salt: str='', max_age: int=None) -> str: ...
|
||||
def get_raw_uri(self) -> str: ...
|
||||
def build_absolute_uri(self, location: str=None) -> str: ...
|
||||
@property
|
||||
def scheme(self) -> str: ...
|
||||
def is_secure(self) -> bool: ...
|
||||
def is_ajax(self) -> bool: ...
|
||||
encoding = ... # type: Optional[str]
|
||||
upload_handlers = ... # type: UploadHandlerList
|
||||
def parse_file_upload(self, META: Dict[str, str], post_data: BinaryIO) -> Tuple['QueryDict', MultiValueDict[str, uploadedfile.UploadedFile]]: ...
|
||||
@property
|
||||
def body(self) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
def read(self, *args: Any, **kwargs: Any) -> bytes: ...
|
||||
def readline(self, *args: Any, **kwargs: Any) -> bytes: ...
|
||||
def xreadlines(self) -> Iterator[bytes]: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def readlines(self) -> List[bytes]: ... # type: ignore
|
||||
|
||||
class QueryDict(MultiValueDict[str, str]):
|
||||
encoding = str # type: Any
|
||||
def __init__(self, query_string: Union[str, bytes, None]=None, mutable: bool=False, encoding: Optional[str]=None) -> None: ...
|
||||
def __setitem__(self, key: str, value: str) -> None: ...
|
||||
def __delitem__(self, key: str) -> None: ...
|
||||
def __copy__(self) -> 'QueryDict': ...
|
||||
def __deepcopy__(self, memo: Dict[int, object]) -> 'QueryDict': ...
|
||||
def setlist(self, key: str, list_: List[str]) -> None: ...
|
||||
def setlistdefault(self, key: str, default_list: List[str]=None) -> List[str]: ...
|
||||
def appendlist(self, key: str, value: str) -> None: ...
|
||||
def pop(self, key: str, default: List[str]=None) -> List[str]: ... # type: ignore
|
||||
def popitem(self) -> Tuple[str, str]: ...
|
||||
def clear(self) -> None: ...
|
||||
def setdefault(self, key: str, default: Optional[str]=None) -> str: ...
|
||||
def copy(self) -> 'QueryDict': ...
|
||||
def urlencode(self, safe: Optional[str]=None) -> str: ...
|
||||
|
||||
@overload
|
||||
def bytes_to_text(s: bytes, encoding: str) -> str: ...
|
||||
@overload
|
||||
def bytes_to_text(s: str, encoding: str) -> str: ...
|
||||
@overload
|
||||
def bytes_to_text(s: None, encoding: str) -> None: ...
|
||||
def split_domain_port(host: str) -> Tuple[str, str]: ...
|
||||
def validate_host(host: str, allowed_hosts: Iterable[str]) -> bool: ...
|
||||
98
django-stubs/http/response.pyi
Normal file
98
django-stubs/http/response.pyi
Normal file
@@ -0,0 +1,98 @@
|
||||
# Stubs for django.http.response (Python 3.5)
|
||||
|
||||
import datetime
|
||||
from json import JSONEncoder
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, overload, Tuple, Type, Union
|
||||
|
||||
from django.http.cookie import SimpleCookie
|
||||
import six
|
||||
|
||||
class BadHeaderError(ValueError): ...
|
||||
|
||||
class HttpResponseBase(six.Iterator):
|
||||
status_code = ... # type: int
|
||||
cookies = ... # type: SimpleCookie
|
||||
closed = ... # type: bool
|
||||
reason_phrase = ... # type: str
|
||||
charset = ... # type: str
|
||||
def __init__(self, content_type: str=None, status: int=None, reason: str=None, charset: str=None) -> None: ...
|
||||
def serialize_headers(self) -> bytes: ...
|
||||
def __bytes__(self) -> bytes: ...
|
||||
def __setitem__(self, header: str, value: Union[str, bytes]) -> None: ...
|
||||
def __delitem__(self, header: str) -> None: ...
|
||||
def __getitem__(self, header: str) -> str: ...
|
||||
def has_header(self, header: str) -> bool: ...
|
||||
def __contains__(self, item: object) -> bool: ...
|
||||
def items(self) -> Iterable[Tuple[str, str]]: ...
|
||||
@overload
|
||||
def get(self, header: str, alternate: str) -> str: ...
|
||||
@overload
|
||||
def get(self, header: str) -> Optional[str]: ...
|
||||
def set_cookie(self, key: str, value: str='', max_age: int=None, expires: Union[str, datetime.datetime]=None, path: str='', domain: str=None, secure: bool=False, httponly: bool=False) -> None: ...
|
||||
def setdefault(self, key: str, value: str) -> None: ...
|
||||
def set_signed_cookie(self, key: str, value: str, salt: str='', **kwargs: Any) -> None: ...
|
||||
def delete_cookie(self, key: str, path: str='', domain: str=None) -> None: ...
|
||||
def make_bytes(self, value: object) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
def write(self, content: object) -> None: ...
|
||||
def flush(self) -> None: ...
|
||||
def tell(self) -> int: ...
|
||||
def readable(self) -> bool: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def writable(self) -> bool: ...
|
||||
def writelines(self, lines: Iterable[object]) -> None: ...
|
||||
|
||||
class HttpResponse(HttpResponseBase):
|
||||
streaming = ... # type: bool
|
||||
def __init__(self, content: object=b'', *args: Any, **kwargs: Any) -> None: ...
|
||||
def serialize(self) -> bytes: ...
|
||||
@property
|
||||
def content(self) -> bytes: ...
|
||||
@content.setter
|
||||
def content(self, value: Any) -> None: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
|
||||
class StreamingHttpResponse(HttpResponseBase):
|
||||
def __init__(self, streaming_content: Iterable[bytes]=..., *args: Any, **kwargs: Any) -> None: ...
|
||||
@property
|
||||
def content(self) -> bytes: ...
|
||||
@property
|
||||
def streaming_content(self) -> Iterator[bytes]: ...
|
||||
@streaming_content.setter
|
||||
def streaming_content(self, value: Iterable[bytes]) -> None: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
|
||||
class FileResponse(StreamingHttpResponse): ...
|
||||
|
||||
class HttpResponseRedirectBase(HttpResponse):
|
||||
allowed_schemes = ... # type: List[str]
|
||||
def __init__(self, redirect_to: str, *args: Any, **kwargs: Any) -> None: ...
|
||||
@property
|
||||
def url(self) -> str: ...
|
||||
|
||||
class HttpResponseRedirect(HttpResponseRedirectBase): ...
|
||||
|
||||
class HttpResponsePermanentRedirect(HttpResponseRedirectBase): ...
|
||||
|
||||
class HttpResponseNotModified(HttpResponse):
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class HttpResponseBadRequest(HttpResponse): ...
|
||||
|
||||
class HttpResponseNotFound(HttpResponse): ...
|
||||
|
||||
class HttpResponseForbidden(HttpResponse): ...
|
||||
|
||||
class HttpResponseNotAllowed(HttpResponse):
|
||||
def __init__(self, permitted_methods: Iterable[str], *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class HttpResponseGone(HttpResponse): ...
|
||||
|
||||
class HttpResponseServerError(HttpResponse): ...
|
||||
|
||||
class Http404(Exception): ...
|
||||
|
||||
class JsonResponse(HttpResponse):
|
||||
def __init__(self, data: object, encoder: Type[JSONEncoder]=..., safe: bool=True, json_dumps_params: Dict[str, Any]=None, **kwargs: Any) -> None: ...
|
||||
Reference in New Issue
Block a user