mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 08:17:08 +08:00
better stubs
This commit is contained in:
@@ -1,70 +1,56 @@
|
||||
# Stubs for django.db.models.fields.files (Python 3.6)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.core.files.images import ImageFile
|
||||
from django.db.models.fields import Field
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
from django.core.files.base import ContentFile, File
|
||||
from django.core.files.storage import Storage
|
||||
from django.core.files.uploadedfile import (
|
||||
InMemoryUploadedFile,
|
||||
SimpleUploadedFile,
|
||||
UploadedFile,
|
||||
)
|
||||
from django.db.models.base import Model
|
||||
from django.forms.fields import FileField
|
||||
from functools import partial
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
from django.core.files.base import File
|
||||
from django.core.files.images import ImageFile
|
||||
from django.core.files.storage import FileSystemStorage, Storage
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields import Field
|
||||
from django.forms.fields import FileField, ImageField
|
||||
|
||||
|
||||
class FieldFile(File):
|
||||
instance: Any = ...
|
||||
field: Any = ...
|
||||
storage: Any = ...
|
||||
_committed: bool = ...
|
||||
def __init__(self, instance: Model, field: FileField, name: Optional[str]) -> None: ...
|
||||
def __eq__(self, other: Optional[Union[str, Tuple, FieldFile]]) -> bool: ...
|
||||
def __hash__(self): ...
|
||||
def _require_file(self) -> None: ...
|
||||
_file: Any = ...
|
||||
def _get_file(self) -> File: ...
|
||||
def _set_file(self, file: Optional[File]) -> None: ...
|
||||
def _del_file(self) -> None: ...
|
||||
instance: django.db.models.base.Model = ...
|
||||
field: django.db.models.fields.files.FileField = ...
|
||||
storage: Union[
|
||||
django.core.files.storage.DefaultStorage,
|
||||
django.core.files.storage.FileSystemStorage,
|
||||
] = ...
|
||||
def __init__(
|
||||
self, instance: Model, field: FileField, name: Optional[str]
|
||||
) -> None: ...
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
file: Any = ...
|
||||
@property
|
||||
def path(self): ...
|
||||
def path(self) -> str: ...
|
||||
@property
|
||||
def url(self) -> str: ...
|
||||
@property
|
||||
def size(self): ...
|
||||
def size(self) -> int: ...
|
||||
def open(self, mode: str = ...) -> FieldFile: ...
|
||||
name: Any = ...
|
||||
def save(
|
||||
self, name: str, content: Union[ContentFile, UploadedFile], save: bool = ...
|
||||
) -> None: ...
|
||||
name: Optional[str] = ...
|
||||
def save(self, name: str, content: File, save: bool = ...) -> None: ...
|
||||
def delete(self, save: bool = ...) -> None: ...
|
||||
@property
|
||||
def closed(self): ...
|
||||
def closed(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def __getstate__(self) -> Dict[str, Optional[Union[str, bool]]]: ...
|
||||
|
||||
class FileDescriptor:
|
||||
field: Any = ...
|
||||
field: django.db.models.fields.files.FileField = ...
|
||||
def __init__(self, field: FileField) -> None: ...
|
||||
def __get__(
|
||||
self, instance: Optional[Model], cls: Type[Model] = ...
|
||||
) -> Union[FileDescriptor, FieldFile]: ...
|
||||
def __set__(
|
||||
self, instance: Model, value: Optional[Union[str, FieldFile, InMemoryUploadedFile]]
|
||||
self, instance: Model, value: Optional[Union[str, File]]
|
||||
) -> None: ...
|
||||
|
||||
class FileField(Field):
|
||||
attr_class: Any = ...
|
||||
descriptor_class: Any = ...
|
||||
description: Any = ...
|
||||
_primary_key_set_explicitly: Any = ...
|
||||
storage: Any = ...
|
||||
upload_to: Any = ...
|
||||
def __init__(
|
||||
@@ -73,26 +59,93 @@ class FileField(Field):
|
||||
name: None = ...,
|
||||
upload_to: Union[str, Callable] = ...,
|
||||
storage: Optional[Storage] = ...,
|
||||
**kwargs: Any,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
def _check_primary_key(self) -> List[Error]: ...
|
||||
def _check_upload_to(self) -> List[Any]: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||
def deconstruct(
|
||||
self
|
||||
) -> Union[
|
||||
Tuple[
|
||||
str,
|
||||
List[Any],
|
||||
Union[
|
||||
Dict[str, Union[int, partial]],
|
||||
Dict[str, Union[Callable, FileSystemStorage]],
|
||||
Dict[str, Union[int, str, FileSystemStorage]],
|
||||
Dict[str, Union[int, str]],
|
||||
],
|
||||
Union[
|
||||
Dict[str, Union[int, partial]],
|
||||
Dict[str, Union[Callable, FileSystemStorage]],
|
||||
Dict[str, Union[int, str, FileSystemStorage]],
|
||||
Dict[str, Union[int, str]],
|
||||
],
|
||||
],
|
||||
Tuple[
|
||||
str,
|
||||
List[Any],
|
||||
Union[
|
||||
Dict[str, Union[bool, Callable, FileSystemStorage]],
|
||||
Dict[str, Union[str, bool]],
|
||||
Dict[str, Union[int, str]],
|
||||
Dict[str, Union[int, partial]],
|
||||
Dict[str, Union[int, str, FileSystemStorage]],
|
||||
Dict[str, Union[bool, str, FileSystemStorage]],
|
||||
],
|
||||
Union[
|
||||
Dict[str, Union[bool, Callable, FileSystemStorage]],
|
||||
Dict[str, Union[str, bool]],
|
||||
Dict[str, Union[int, str]],
|
||||
Dict[str, Union[int, partial]],
|
||||
Dict[str, Union[int, str, FileSystemStorage]],
|
||||
Dict[str, Union[bool, str, FileSystemStorage]],
|
||||
],
|
||||
],
|
||||
Tuple[
|
||||
str,
|
||||
List[Any],
|
||||
Dict[str, Union[str, FileSystemStorage]],
|
||||
Union[Dict[str, Union[str, FileSystemStorage]], Dict[str, str]],
|
||||
],
|
||||
Tuple[
|
||||
None,
|
||||
str,
|
||||
List[Any],
|
||||
Union[
|
||||
Dict[str, Union[bool, Callable, FileSystemStorage]],
|
||||
Dict[str, Union[str, bool]],
|
||||
],
|
||||
],
|
||||
Tuple[str, str, List[Any], Dict[str, Union[str, FileSystemStorage]]],
|
||||
]: ...
|
||||
def get_internal_type(self) -> str: ...
|
||||
def get_prep_value(self, value: FieldFile) -> str: ...
|
||||
def get_prep_value(self, value: Union[str, FieldFile]) -> str: ...
|
||||
def pre_save(self, model_instance: Model, add: bool) -> FieldFile: ...
|
||||
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
|
||||
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
|
||||
def contribute_to_class(
|
||||
self, cls: Type[Model], name: str, **kwargs: Any
|
||||
) -> None: ...
|
||||
def generate_filename(
|
||||
self, instance: Optional[Model], filename: str
|
||||
) -> str: ...
|
||||
def save_form_data(
|
||||
self, instance: Model, data: Optional[Union[bool, FieldFile, SimpleUploadedFile]]
|
||||
self, instance: Model, data: Optional[Union[bool, File, str]]
|
||||
) -> None: ...
|
||||
def formfield(self, **kwargs: Any) -> FileField: ...
|
||||
|
||||
class ImageFileDescriptor(FileDescriptor):
|
||||
def __set__(self, instance: Any, value: Any) -> None: ...
|
||||
field: django.db.models.fields.files.ImageField
|
||||
def __set__(
|
||||
self, instance: Model, value: Optional[Union[str, File]]
|
||||
) -> None: ...
|
||||
|
||||
class ImageFieldFile(ImageFile, FieldFile):
|
||||
field: django.db.models.fields.files.ImageField
|
||||
instance: django.db.models.base.Model
|
||||
name: Optional[str]
|
||||
storage: Union[
|
||||
django.core.files.storage.DefaultStorage,
|
||||
django.core.files.storage.FileSystemStorage,
|
||||
]
|
||||
def delete(self, save: bool = ...) -> None: ...
|
||||
|
||||
class ImageField(FileField):
|
||||
@@ -101,17 +154,52 @@ class ImageField(FileField):
|
||||
description: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[Any] = ...,
|
||||
name: Optional[Any] = ...,
|
||||
width_field: Optional[Any] = ...,
|
||||
height_field: Optional[Any] = ...,
|
||||
**kwargs: Any,
|
||||
verbose_name: None = ...,
|
||||
name: None = ...,
|
||||
width_field: Optional[str] = ...,
|
||||
height_field: Optional[str] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
def deconstruct(
|
||||
self
|
||||
) -> Union[
|
||||
Tuple[
|
||||
str,
|
||||
List[Any],
|
||||
Union[
|
||||
Dict[str, Union[Callable, FileSystemStorage, str]],
|
||||
Dict[str, Union[bool, str, FileSystemStorage]],
|
||||
Dict[str, Union[bool, Callable, FileSystemStorage, str]],
|
||||
],
|
||||
Union[
|
||||
Dict[str, Union[Callable, FileSystemStorage, str]],
|
||||
Dict[str, Union[str, FileSystemStorage]],
|
||||
Dict[str, Union[bool, str, FileSystemStorage]],
|
||||
Dict[str, Union[bool, Callable, FileSystemStorage, str]],
|
||||
],
|
||||
],
|
||||
Tuple[
|
||||
str,
|
||||
List[Any],
|
||||
Dict[str, Union[str, bool]],
|
||||
Union[Dict[str, Union[str, bool]], Dict[str, str]],
|
||||
],
|
||||
Tuple[
|
||||
None,
|
||||
str,
|
||||
List[Any],
|
||||
Union[
|
||||
Dict[str, Union[str, FileSystemStorage]],
|
||||
Dict[str, Union[str, bool]],
|
||||
Dict[str, Union[bool, str, FileSystemStorage]],
|
||||
],
|
||||
],
|
||||
]: ...
|
||||
def contribute_to_class(
|
||||
self, cls: Type[Model], name: str, **kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any): ...
|
||||
def _check_image_library_installed(self): ...
|
||||
def deconstruct(self): ...
|
||||
def contribute_to_class(self, cls: Any, name: Any, **kwargs: Any) -> None: ...
|
||||
def update_dimension_fields(
|
||||
self, instance: Any, force: bool = ..., *args: Any, **kwargs: Any
|
||||
): ...
|
||||
def formfield(self, **kwargs: Any): ...
|
||||
self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any
|
||||
) -> None: ...
|
||||
def formfield(self, **kwargs: Any) -> ImageField: ...
|
||||
|
||||
Reference in New Issue
Block a user