mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 08:17:08 +08:00
initial commit
This commit is contained in:
36
django/core/files/base.pyi
Normal file
36
django/core/files/base.pyi
Normal file
@@ -0,0 +1,36 @@
|
||||
from typing import (
|
||||
Any,
|
||||
Iterator,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def endswith_cr(line: bytes) -> bool: ...
|
||||
|
||||
|
||||
def endswith_lf(line: Union[str, bytes]) -> bool: ...
|
||||
|
||||
|
||||
def equals_lf(line: bytes) -> bool: ...
|
||||
|
||||
|
||||
class ContentFile:
|
||||
def __bool__(self) -> bool: ...
|
||||
def __init__(self, content: Union[str, bytes], name: Optional[str] = ...) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
|
||||
class File:
|
||||
def __bool__(self) -> bool: ...
|
||||
def __enter__(self) -> File: ...
|
||||
def __exit__(self, exc_type: None, exc_value: None, tb: None) -> None: ...
|
||||
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
|
||||
def __iter__(self) -> Iterator[Union[str, bytes]]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __str__(self) -> str: ...
|
||||
def chunks(self, chunk_size: None = ...) -> Iterator[Union[str, bytes]]: ...
|
||||
def close(self) -> None: ...
|
||||
@cached_property
|
||||
def size(self) -> int: ...
|
||||
11
django/core/files/locks.pyi
Normal file
11
django/core/files/locks.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from io import BufferedRandom
|
||||
from typing import Union
|
||||
|
||||
|
||||
def _fd(f: Union[BufferedRandom, int]) -> int: ...
|
||||
|
||||
|
||||
def lock(f: Union[BufferedRandom, int], flags: int) -> bool: ...
|
||||
|
||||
|
||||
def unlock(f: int) -> bool: ...
|
||||
9
django/core/files/move.pyi
Normal file
9
django/core/files/move.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
def _samefile(src: str, dst: str) -> bool: ...
|
||||
|
||||
|
||||
def file_move_safe(
|
||||
old_file_name: str,
|
||||
new_file_name: str,
|
||||
chunk_size: int = ...,
|
||||
allow_overwrite: bool = ...
|
||||
) -> None: ...
|
||||
67
django/core/files/storage.pyi
Normal file
67
django/core/files/storage.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
from io import StringIO
|
||||
from datetime import datetime
|
||||
from django.core.files.base import File
|
||||
from typing import (
|
||||
Any,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def get_storage_class(import_path: Optional[str] = ...) -> Any: ...
|
||||
|
||||
|
||||
class FileSystemStorage:
|
||||
def __init__(
|
||||
self,
|
||||
location: Optional[str] = ...,
|
||||
base_url: Optional[str] = ...,
|
||||
file_permissions_mode: Optional[int] = ...,
|
||||
directory_permissions_mode: Optional[int] = ...
|
||||
) -> None: ...
|
||||
def _clear_cached_properties(self, setting: str, **kwargs) -> None: ...
|
||||
def _datetime_from_timestamp(self, ts: float) -> datetime: ...
|
||||
def _open(self, name: str, mode: str = ...) -> File: ...
|
||||
def _save(self, name: str, content: File) -> str: ...
|
||||
def _value_or_setting(
|
||||
self,
|
||||
value: Optional[Union[str, int]],
|
||||
setting: Optional[Union[str, int]]
|
||||
) -> Optional[Union[str, int]]: ...
|
||||
@cached_property
|
||||
def base_location(self) -> str: ...
|
||||
@cached_property
|
||||
def base_url(self) -> str: ...
|
||||
def delete(self, name: str) -> None: ...
|
||||
@cached_property
|
||||
def directory_permissions_mode(self) -> Optional[int]: ...
|
||||
def exists(self, name: str) -> bool: ...
|
||||
@cached_property
|
||||
def file_permissions_mode(self) -> Optional[int]: ...
|
||||
def get_accessed_time(self, name: str) -> datetime: ...
|
||||
def get_created_time(self, name: str) -> datetime: ...
|
||||
def get_modified_time(self, name: str) -> datetime: ...
|
||||
def listdir(
|
||||
self,
|
||||
path: str
|
||||
) -> Union[Tuple[List[Any], List[Any]], Tuple[List[Any], List[str]], Tuple[List[str], List[Any]], Tuple[List[str], List[str]]]: ...
|
||||
@cached_property
|
||||
def location(self) -> str: ...
|
||||
def path(self, name: str) -> str: ...
|
||||
def size(self, name: str) -> int: ...
|
||||
def url(self, name: str) -> str: ...
|
||||
|
||||
|
||||
class Storage:
|
||||
def generate_filename(self, filename: str) -> str: ...
|
||||
def get_available_name(self, name: str, max_length: Optional[int] = ...) -> str: ...
|
||||
def get_valid_name(self, name: str) -> str: ...
|
||||
def open(self, name: str, mode: str = ...) -> File: ...
|
||||
def save(
|
||||
self,
|
||||
name: Optional[str],
|
||||
content: Union[StringIO, File],
|
||||
max_length: Optional[int] = ...
|
||||
) -> str: ...
|
||||
57
django/core/files/uploadedfile.pyi
Normal file
57
django/core/files/uploadedfile.pyi
Normal file
@@ -0,0 +1,57 @@
|
||||
from io import (
|
||||
BytesIO,
|
||||
StringIO,
|
||||
)
|
||||
from tempfile import _TemporaryFileWrapper
|
||||
from typing import (
|
||||
Iterator,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class InMemoryUploadedFile:
|
||||
def __init__(
|
||||
self,
|
||||
file: Union[StringIO, BytesIO],
|
||||
field_name: Optional[str],
|
||||
name: str,
|
||||
content_type: str,
|
||||
size: int,
|
||||
charset: Optional[str],
|
||||
content_type_extra: None = ...
|
||||
) -> None: ...
|
||||
def chunks(self, chunk_size: None = ...) -> Iterator[Union[str, bytes]]: ...
|
||||
def open(self, mode: None = ...) -> InMemoryUploadedFile: ...
|
||||
|
||||
|
||||
class SimpleUploadedFile:
|
||||
def __init__(self, name: str, content: Optional[bytes], content_type: str = ...) -> None: ...
|
||||
|
||||
|
||||
class TemporaryUploadedFile:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
content_type: str,
|
||||
size: int,
|
||||
charset: str,
|
||||
content_type_extra: None = ...
|
||||
) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def temporary_file_path(self) -> str: ...
|
||||
|
||||
|
||||
class UploadedFile:
|
||||
def __init__(
|
||||
self,
|
||||
file: Optional[Union[_TemporaryFileWrapper, StringIO, BytesIO]] = ...,
|
||||
name: str = ...,
|
||||
content_type: str = ...,
|
||||
size: Optional[int] = ...,
|
||||
charset: Optional[str] = ...,
|
||||
content_type_extra: None = ...
|
||||
) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def _get_name(self) -> str: ...
|
||||
def _set_name(self, name: str) -> None: ...
|
||||
57
django/core/files/uploadhandler.pyi
Normal file
57
django/core/files/uploadhandler.pyi
Normal file
@@ -0,0 +1,57 @@
|
||||
from io import BytesIO
|
||||
from django.core.files.uploadedfile import (
|
||||
InMemoryUploadedFile,
|
||||
TemporaryUploadedFile,
|
||||
)
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def load_handler(path: str, *args, **kwargs) -> FileUploadHandler: ...
|
||||
|
||||
|
||||
class FileUploadHandler:
|
||||
def __init__(self, request: WSGIRequest = ...) -> None: ...
|
||||
def handle_raw_input(
|
||||
self,
|
||||
input_data: WSGIRequest,
|
||||
META: Dict[str, Any],
|
||||
content_length: int,
|
||||
boundary: bytes,
|
||||
encoding: str = ...
|
||||
) -> None: ...
|
||||
def new_file(
|
||||
self,
|
||||
field_name: str,
|
||||
file_name: str,
|
||||
content_type: str,
|
||||
content_length: None,
|
||||
charset: None = ...,
|
||||
content_type_extra: Dict[Any, Any] = ...
|
||||
) -> None: ...
|
||||
def upload_complete(self) -> None: ...
|
||||
|
||||
|
||||
class MemoryFileUploadHandler:
|
||||
def file_complete(self, file_size: int) -> Optional[InMemoryUploadedFile]: ...
|
||||
def handle_raw_input(
|
||||
self,
|
||||
input_data: Union[BytesIO, WSGIRequest],
|
||||
META: Dict[str, Any],
|
||||
content_length: int,
|
||||
boundary: bytes,
|
||||
encoding: str = ...
|
||||
) -> None: ...
|
||||
def new_file(self, *args, **kwargs) -> None: ...
|
||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
||||
|
||||
|
||||
class TemporaryFileUploadHandler:
|
||||
def file_complete(self, file_size: int) -> TemporaryUploadedFile: ...
|
||||
def new_file(self, *args, **kwargs) -> None: ...
|
||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> None: ...
|
||||
4
django/core/files/utils.pyi
Normal file
4
django/core/files/utils.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
class FileProxyMixin:
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
def readable(self) -> bool: ...
|
||||
Reference in New Issue
Block a user