mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 00:07:09 +08:00
Add typechecking for 'file_storage', 'files' test folders (#101)
* add typechecking for 'file_storage', 'files' test folders * fix File class annotations
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
from io import StringIO
|
||||
from typing import Any, Iterator, Optional, Union
|
||||
from typing import Any, Iterator, Optional, Union, IO, Type
|
||||
from types import TracebackType
|
||||
|
||||
from django.core.files.utils import FileProxyMixin
|
||||
|
||||
class File(FileProxyMixin):
|
||||
class File(FileProxyMixin, IO[Any]):
|
||||
DEFAULT_CHUNK_SIZE: Any = ...
|
||||
file: StringIO = ...
|
||||
name: Optional[str] = ...
|
||||
name: str = ...
|
||||
mode: str = ...
|
||||
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
@@ -15,8 +16,11 @@ class File(FileProxyMixin):
|
||||
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[Union[bytes, bytearray]]: ...
|
||||
def multiple_chunks(self, chunk_size: Optional[Any] = ...): ...
|
||||
def __iter__(self) -> Iterator[Union[bytes, str]]: ...
|
||||
def __next__(self) -> Union[bytes, str]: ...
|
||||
def __enter__(self) -> File: ...
|
||||
def __exit__(self, exc_type: None, exc_value: None, tb: None) -> None: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], tb: Optional[TracebackType]
|
||||
) -> bool: ...
|
||||
def open(self, mode: Optional[str] = ...) -> File: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from io import BytesIO
|
||||
from typing import Any, Union
|
||||
from typing import Any, IO, Union
|
||||
|
||||
from django.core.files import File
|
||||
|
||||
@@ -11,4 +10,4 @@ class ImageFile(File):
|
||||
@property
|
||||
def height(self) -> int: ...
|
||||
|
||||
def get_image_dimensions(file_or_path: Union[BytesIO, str], close: bool = ...) -> Any: ...
|
||||
def get_image_dimensions(file_or_path: Union[str, IO[bytes]], close: bool = ...) -> Any: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, IO, List, Optional, Tuple
|
||||
from typing import Any, List, Optional, Tuple, IO
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.utils.functional import LazyObject
|
||||
|
||||
Reference in New Issue
Block a user