mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-18 01:45:59 +08:00
better stubs
This commit is contained in:
@@ -1,110 +1,300 @@
|
||||
from io import BufferedReader, BytesIO, TextIOWrapper
|
||||
from datetime import datetime
|
||||
from io import BufferedReader, BytesIO
|
||||
from tempfile import _TemporaryFileWrapper
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from tempfile import _TemporaryFileWrapper
|
||||
from typing import Dict, List, Optional, Tuple, Type, Union
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
class FileResponse:
|
||||
def __init__(self, *args, as_attachment=..., filename=..., **kwargs) -> None: ...
|
||||
def _set_streaming_content(
|
||||
self, value: Union[_TemporaryFileWrapper, BufferedReader, ContentFile]
|
||||
) -> None: ...
|
||||
def set_headers(
|
||||
self, filelike: Union[_TemporaryFileWrapper, BufferedReader, BytesIO]
|
||||
) -> None: ...
|
||||
|
||||
class HttpResponse:
|
||||
def __init__(
|
||||
self, content: Union[int, TextIOWrapper, bytes, str] = ..., *args, **kwargs
|
||||
) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
def writable(self) -> bool: ...
|
||||
def write(self, content: Union[str, bytes]) -> None: ...
|
||||
def writelines(self, lines: List[str]) -> None: ...
|
||||
class BadHeaderError(ValueError): ...
|
||||
|
||||
class HttpResponseBase:
|
||||
def __delitem__(self, header: str) -> None: ...
|
||||
def __getitem__(self, header: str) -> str: ...
|
||||
status_code: int = ...
|
||||
cookies: http.cookies.SimpleCookie = ...
|
||||
closed: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
content_type: Optional[str] = ...,
|
||||
status: Optional[Union[str, int]] = ...,
|
||||
status: Any = ...,
|
||||
reason: Optional[str] = ...,
|
||||
charset: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def reason_phrase(self): ...
|
||||
@reason_phrase.setter
|
||||
def reason_phrase(self, value: Any) -> None: ...
|
||||
@property
|
||||
def charset(self): ...
|
||||
@charset.setter
|
||||
def charset(self, value: Any) -> None: ...
|
||||
def serialize_headers(self) -> bytes: ...
|
||||
__bytes__: Any = ...
|
||||
def __setitem__(
|
||||
self, header: Union[str, bytes], value: Union[str, bytes, int]
|
||||
) -> None: ...
|
||||
@property
|
||||
def _content_type_for_repr(self) -> str: ...
|
||||
def _convert_to_charset(
|
||||
self, value: Union[str, int], charset: str, mime_encode: bool = ...
|
||||
) -> str: ...
|
||||
def close(self) -> None: ...
|
||||
def delete_cookie(
|
||||
self, key: str, path: str = ..., domain: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def __delitem__(self, header: str) -> None: ...
|
||||
def __getitem__(self, header: str) -> str: ...
|
||||
def has_header(self, header: str) -> bool: ...
|
||||
__contains__: Any = ...
|
||||
def items(self): ...
|
||||
def get(
|
||||
self, header: str, alternate: Optional[Union[str, Tuple]] = ...
|
||||
) -> Optional[Union[str, Tuple]]: ...
|
||||
def has_header(self, header: str) -> bool: ...
|
||||
def make_bytes(self, value: Union[bytes, int, str]) -> bytes: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def serialize_headers(self) -> bytes: ...
|
||||
def set_cookie(
|
||||
self,
|
||||
key: str,
|
||||
value: str = ...,
|
||||
max_age: Optional[int] = ...,
|
||||
expires: Optional[str] = ...,
|
||||
expires: Optional[Union[str, datetime]] = ...,
|
||||
path: str = ...,
|
||||
domain: Optional[str] = ...,
|
||||
secure: Optional[bool] = ...,
|
||||
httponly: bool = ...,
|
||||
httponly: Optional[bool] = ...,
|
||||
samesite: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def set_signed_cookie(
|
||||
self, key: str, value: str, salt: str = ..., **kwargs
|
||||
) -> None: ...
|
||||
def setdefault(self, key: str, value: str) -> None: ...
|
||||
def tell(self): ...
|
||||
def write(self, content: str): ...
|
||||
def writelines(self, lines: List[str]): ...
|
||||
def set_signed_cookie(
|
||||
self, key: str, value: str, salt: str = ..., **kwargs: Any
|
||||
) -> None: ...
|
||||
def delete_cookie(
|
||||
self, key: str, path: str = ..., domain: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def make_bytes(
|
||||
self, value: Union[int, SimpleLazyObject, bytes, str]
|
||||
) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
def write(self, content: str) -> Any: ...
|
||||
def flush(self) -> None: ...
|
||||
def tell(self) -> Any: ...
|
||||
def readable(self) -> bool: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def writable(self) -> bool: ...
|
||||
def writelines(self, lines: List[str]) -> Any: ...
|
||||
|
||||
class HttpResponseNotAllowed:
|
||||
def __init__(self, permitted_methods: List[str], *args, **kwargs) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
|
||||
class HttpResponseNotModified:
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
|
||||
class HttpResponseRedirectBase:
|
||||
def __init__(self, redirect_to: str, *args, **kwargs) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
|
||||
class JsonResponse:
|
||||
class HttpResponse(HttpResponseBase):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: Optional[
|
||||
Union[django.template.context.Context, django.test.utils.ContextList]
|
||||
]
|
||||
cookies: http.cookies.SimpleCookie
|
||||
csrf_cookie_set: bool
|
||||
json: functools.partial
|
||||
redirect_chain: List[Tuple[str, int]]
|
||||
request: Dict[str, Union[str, int, django.test.client.FakePayload]]
|
||||
resolver_match: Union[
|
||||
django.utils.functional.SimpleLazyObject,
|
||||
django.urls.resolvers.ResolverMatch,
|
||||
]
|
||||
sameorigin: bool
|
||||
status_code: int
|
||||
templates: List[django.template.base.Template]
|
||||
test_server_port: str
|
||||
test_was_secure_request: bool
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
xframe_options_exempt: bool
|
||||
streaming: bool = ...
|
||||
content: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
data: Dict[str, Union[Dict[str, bool], str, Dict[str, str], List[Dict[str, str]]]],
|
||||
encoder: Type[DjangoJSONEncoder] = ...,
|
||||
safe: bool = ...,
|
||||
json_dumps_params: None = ...,
|
||||
**kwargs,
|
||||
) -> None: ...
|
||||
|
||||
class StreamingHttpResponse:
|
||||
def __init__(
|
||||
self,
|
||||
streaming_content: Union[
|
||||
_TemporaryFileWrapper, BufferedReader, str, List[str]
|
||||
] = ...,
|
||||
*args,
|
||||
**kwargs,
|
||||
) -> None: ...
|
||||
def __iter__(self) -> map: ...
|
||||
def _set_streaming_content(
|
||||
self, value: Union[TextIOWrapper, str, List[str], List[bytes]]
|
||||
self, content: Any = ..., *args: Any, **kwargs: Any
|
||||
) -> None: ...
|
||||
def serialize(self): ...
|
||||
__bytes__: Any = ...
|
||||
@property
|
||||
def content(self): ...
|
||||
@content.setter
|
||||
def content(self, value: Any) -> None: ...
|
||||
def __iter__(self): ...
|
||||
def write(self, content: Union[str, bytes]) -> None: ...
|
||||
def tell(self) -> int: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
def writable(self) -> bool: ...
|
||||
def writelines(self, lines: List[str]) -> None: ...
|
||||
|
||||
class StreamingHttpResponse(HttpResponseBase):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: None
|
||||
cookies: http.cookies.SimpleCookie
|
||||
json: functools.partial
|
||||
request: Dict[str, Union[str, int, django.test.client.FakePayload]]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
status_code: int
|
||||
templates: List[Any]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
streaming: bool = ...
|
||||
streaming_content: Any = ...
|
||||
def __init__(
|
||||
self, streaming_content: Any = ..., *args: Any, **kwargs: Any
|
||||
) -> None: ...
|
||||
@property
|
||||
def content(self) -> Any: ...
|
||||
@property
|
||||
def streaming_content(self): ...
|
||||
@streaming_content.setter
|
||||
def streaming_content(self, value: Any) -> None: ...
|
||||
def __iter__(self) -> map: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
|
||||
class FileResponse(StreamingHttpResponse):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: None
|
||||
cookies: http.cookies.SimpleCookie
|
||||
file_to_stream: Optional[
|
||||
Union[
|
||||
_io.BytesIO,
|
||||
tempfile._TemporaryFileWrapper,
|
||||
_io.BufferedReader,
|
||||
django.core.files.base.ContentFile,
|
||||
]
|
||||
]
|
||||
json: functools.partial
|
||||
request: Dict[str, str]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
templates: List[Any]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
block_size: int = ...
|
||||
as_attachment: bool = ...
|
||||
filename: str = ...
|
||||
def __init__(
|
||||
self,
|
||||
*args: Any,
|
||||
as_attachment: bool = ...,
|
||||
filename: str = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def set_headers(
|
||||
self,
|
||||
filelike: Union[
|
||||
_TemporaryFileWrapper, ContentFile, BufferedReader, BytesIO
|
||||
],
|
||||
) -> None: ...
|
||||
|
||||
class HttpResponseRedirectBase(HttpResponse):
|
||||
allowed_schemes: Any = ...
|
||||
def __init__(self, redirect_to: str, *args: Any, **kwargs: Any) -> None: ...
|
||||
url: Any = ...
|
||||
|
||||
class HttpResponseRedirect(HttpResponseRedirectBase):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: Optional[django.test.utils.ContextList]
|
||||
cookies: http.cookies.SimpleCookie
|
||||
csrf_cookie_set: bool
|
||||
json: functools.partial
|
||||
redirect_chain: List[Tuple[str, int]]
|
||||
request: Dict[
|
||||
str, Union[str, int, django.test.client.FakePayload, Dict[str, str]]
|
||||
]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
templates: List[django.template.base.Template]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
|
||||
class HttpResponsePermanentRedirect(HttpResponseRedirectBase):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: None
|
||||
cookies: http.cookies.SimpleCookie
|
||||
json: functools.partial
|
||||
redirect_chain: List[Tuple[str, int]]
|
||||
request: Dict[str, str]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
templates: List[Any]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
|
||||
class HttpResponseNotModified(HttpResponse):
|
||||
closed: bool
|
||||
cookies: http.cookies.SimpleCookie
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def content(self, value: Any) -> None: ...
|
||||
|
||||
class HttpResponseBadRequest(HttpResponse):
|
||||
closed: bool
|
||||
cookies: http.cookies.SimpleCookie
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
|
||||
class HttpResponseNotFound(HttpResponse):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: Optional[django.template.context.Context]
|
||||
cookies: http.cookies.SimpleCookie
|
||||
csrf_cookie_set: bool
|
||||
json: functools.partial
|
||||
request: Dict[str, str]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
templates: List[django.template.base.Template]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
|
||||
class HttpResponseForbidden(HttpResponse):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: Optional[django.template.context.Context]
|
||||
cookies: http.cookies.SimpleCookie
|
||||
csrf_cookie_set: bool
|
||||
json: functools.partial
|
||||
request: Dict[str, Union[str, int, django.test.client.FakePayload]]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
templates: List[django.template.base.Template]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
|
||||
class HttpResponseNotAllowed(HttpResponse):
|
||||
closed: bool
|
||||
cookies: http.cookies.SimpleCookie
|
||||
status_code: int = ...
|
||||
def __init__(
|
||||
self,
|
||||
permitted_methods: Union[Tuple[str, str], List[str]],
|
||||
*args: Any,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
|
||||
class HttpResponseGone(HttpResponse):
|
||||
closed: bool
|
||||
cookies: http.cookies.SimpleCookie
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
|
||||
class HttpResponseServerError(HttpResponse):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: django.test.utils.ContextList
|
||||
cookies: http.cookies.SimpleCookie
|
||||
csrf_cookie_set: bool
|
||||
json: functools.partial
|
||||
request: Dict[str, str]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
templates: List[django.template.base.Template]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
status_code: int = ...
|
||||
|
||||
class Http404(Exception): ...
|
||||
|
||||
class JsonResponse(HttpResponse):
|
||||
client: django.test.client.Client
|
||||
closed: bool
|
||||
context: None
|
||||
cookies: http.cookies.SimpleCookie
|
||||
json: functools.partial
|
||||
request: Dict[str, Union[str, int, django.test.client.FakePayload]]
|
||||
resolver_match: django.utils.functional.SimpleLazyObject
|
||||
status_code: int
|
||||
templates: List[Any]
|
||||
wsgi_request: django.core.handlers.wsgi.WSGIRequest
|
||||
def __init__(
|
||||
self,
|
||||
data: Any,
|
||||
encoder: Type[DjangoJSONEncoder] = ...,
|
||||
safe: bool = ...,
|
||||
json_dumps_params: Optional[Dict[str, int]] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user