mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 16:27:09 +08:00
third iteration of stubs
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
from http.client import HTTPResponse
|
||||
from io import (BufferedRandom, BufferedReader, BufferedWriter, BytesIO,
|
||||
StringIO, TextIOWrapper)
|
||||
from tempfile import SpooledTemporaryFile, _TemporaryFileWrapper
|
||||
from typing import Any, Iterator, Optional, Union
|
||||
|
||||
from django.core.files.utils import FileProxyMixin
|
||||
@@ -8,15 +12,31 @@ class File(FileProxyMixin):
|
||||
file: _io.BufferedReader = ...
|
||||
name: str = ...
|
||||
mode: str = ...
|
||||
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
file: Optional[
|
||||
Union[
|
||||
BufferedRandom,
|
||||
BufferedReader,
|
||||
BufferedWriter,
|
||||
BytesIO,
|
||||
StringIO,
|
||||
TextIOWrapper,
|
||||
HTTPResponse,
|
||||
SpooledTemporaryFile,
|
||||
_TemporaryFileWrapper,
|
||||
]
|
||||
],
|
||||
name: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
def __len__(self) -> int: ...
|
||||
def size(self) -> int: ...
|
||||
def chunks(
|
||||
self, chunk_size: Optional[int] = ...
|
||||
) -> Iterator[Union[str, bytes]]: ...
|
||||
) -> Iterator[Union[bytes, str]]: ...
|
||||
def multiple_chunks(self, chunk_size: Optional[Any] = ...): ...
|
||||
def __iter__(self) -> Iterator[Union[str, bytes]]: ...
|
||||
def __iter__(self) -> Iterator[Union[bytes, str]]: ...
|
||||
def __enter__(self) -> File: ...
|
||||
def __exit__(self, exc_type: None, exc_value: None, tb: None) -> None: ...
|
||||
def open(self, mode: Optional[str] = ...) -> File: ...
|
||||
@@ -27,7 +47,7 @@ class ContentFile(File):
|
||||
name: None
|
||||
size: Any = ...
|
||||
def __init__(
|
||||
self, content: Union[str, bytes], name: Optional[str] = ...
|
||||
self, content: Union[bytes, str], name: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
def open(self, mode: Optional[str] = ...) -> ContentFile: ...
|
||||
@@ -35,5 +55,5 @@ class ContentFile(File):
|
||||
def write(self, data: str) -> int: ...
|
||||
|
||||
def endswith_cr(line: bytes) -> bool: ...
|
||||
def endswith_lf(line: Union[str, bytes]) -> bool: ...
|
||||
def endswith_lf(line: Union[bytes, str]) -> bool: ...
|
||||
def equals_lf(line: bytes) -> bool: ...
|
||||
|
||||
@@ -14,6 +14,6 @@ class ImageFile(File):
|
||||
def height(self) -> int: ...
|
||||
|
||||
def get_image_dimensions(
|
||||
file_or_path: Union[BytesIO, BufferedReader, str, ImageFile],
|
||||
file_or_path: Union[BufferedReader, BytesIO, ImageFile, str],
|
||||
close: bool = ...,
|
||||
) -> Any: ...
|
||||
|
||||
@@ -13,5 +13,5 @@ class _OFFSET(Structure): ...
|
||||
class _OFFSET_UNION(Union): ...
|
||||
class OVERLAPPED(Structure): ...
|
||||
|
||||
def lock(f: Union[TextIOWrapper, BufferedRandom, int], flags: int) -> bool: ...
|
||||
def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ...
|
||||
def unlock(f: Union[BufferedRandom, int]) -> bool: ...
|
||||
|
||||
@@ -11,7 +11,7 @@ class Storage:
|
||||
def save(
|
||||
self,
|
||||
name: Optional[str],
|
||||
content: Union[TextIOWrapper, StringIO, File],
|
||||
content: Union[StringIO, TextIOWrapper, File],
|
||||
max_length: Optional[int] = ...,
|
||||
) -> str: ...
|
||||
def get_valid_name(self, name: str) -> str: ...
|
||||
|
||||
@@ -13,7 +13,7 @@ class UploadedFile(File):
|
||||
content_type_extra: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
file: Optional[Union[_TemporaryFileWrapper, StringIO, BytesIO]] = ...,
|
||||
file: Optional[Union[BytesIO, StringIO, _TemporaryFileWrapper]] = ...,
|
||||
name: str = ...,
|
||||
content_type: str = ...,
|
||||
size: Optional[int] = ...,
|
||||
@@ -41,7 +41,7 @@ class InMemoryUploadedFile(UploadedFile):
|
||||
field_name: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
file: Union[StringIO, BytesIO],
|
||||
file: Union[BytesIO, StringIO],
|
||||
field_name: Optional[str],
|
||||
name: str,
|
||||
content_type: str,
|
||||
@@ -50,7 +50,7 @@ class InMemoryUploadedFile(UploadedFile):
|
||||
content_type_extra: Optional[Dict[str, bytes]] = ...,
|
||||
) -> None: ...
|
||||
def open(self, mode: Optional[str] = ...) -> InMemoryUploadedFile: ...
|
||||
def chunks(self, chunk_size: None = ...) -> Iterator[Union[str, bytes]]: ...
|
||||
def chunks(self, chunk_size: None = ...) -> Iterator[Union[bytes, str]]: ...
|
||||
def multiple_chunks(self, chunk_size: Optional[Any] = ...): ...
|
||||
|
||||
class SimpleUploadedFile(InMemoryUploadedFile):
|
||||
@@ -58,7 +58,7 @@ class SimpleUploadedFile(InMemoryUploadedFile):
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
content: Optional[Union[str, bytes]],
|
||||
content: Optional[Union[bytes, str]],
|
||||
content_type: str = ...,
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from io import BytesIO
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any, Dict, Optional, Tuple, Union
|
||||
|
||||
from django.core.files.uploadedfile import (InMemoryUploadedFile,
|
||||
TemporaryUploadedFile)
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.test.client import FakePayload
|
||||
|
||||
|
||||
class UploadFileException(Exception): ...
|
||||
@@ -26,8 +27,13 @@ class FileUploadHandler:
|
||||
def __init__(self, request: Optional[WSGIRequest] = ...) -> None: ...
|
||||
def handle_raw_input(
|
||||
self,
|
||||
input_data: Union[WSGIRequest, BytesIO],
|
||||
META: Dict[str, Any],
|
||||
input_data: Union[BytesIO, WSGIRequest],
|
||||
META: Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[str, str], Tuple[int, int], BytesIO, FakePayload, int, str
|
||||
],
|
||||
],
|
||||
content_length: int,
|
||||
boundary: bytes,
|
||||
encoding: str = ...,
|
||||
@@ -68,8 +74,13 @@ class MemoryFileUploadHandler(FileUploadHandler):
|
||||
activated: Any = ...
|
||||
def handle_raw_input(
|
||||
self,
|
||||
input_data: Union[WSGIRequest, BytesIO],
|
||||
META: Dict[str, Any],
|
||||
input_data: Union[BytesIO, WSGIRequest],
|
||||
META: Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[str, str], Tuple[int, int], BytesIO, FakePayload, int, str
|
||||
],
|
||||
],
|
||||
content_length: int,
|
||||
boundary: bytes,
|
||||
encoding: str = ...,
|
||||
|
||||
Reference in New Issue
Block a user