mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 16:57:12 +08:00
Correct the type of FileField.storage (#731)
* Correct the type of FileField.storage This instance property can't be a callable. Although the FileField constructor allows a callable, it is immediately resolved to an instance of Storage. See:f5802a21c4/django/db/models/fields/files.py (L231-L235)* Correct the type of FieldFile.storage This instance property is copied directly from `FileField.storage` and should be the same type. See:f5802a21c4/django/db/models/fields/files.py (L21)
This commit is contained in:
@@ -3,14 +3,14 @@ from typing import Any, Callable, Iterable, Optional, Type, TypeVar, Union, over
|
|||||||
|
|
||||||
from django.core.files.base import File
|
from django.core.files.base import File
|
||||||
from django.core.files.images import ImageFile
|
from django.core.files.images import ImageFile
|
||||||
from django.core.files.storage import FileSystemStorage, Storage
|
from django.core.files.storage import Storage
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
|
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
|
||||||
|
|
||||||
class FieldFile(File):
|
class FieldFile(File):
|
||||||
instance: Model = ...
|
instance: Model = ...
|
||||||
field: FileField = ...
|
field: FileField = ...
|
||||||
storage: FileSystemStorage = ...
|
storage: Storage = ...
|
||||||
def __init__(self, instance: Model, field: FileField, name: Optional[str]) -> None: ...
|
def __init__(self, instance: Model, field: FileField, name: Optional[str]) -> None: ...
|
||||||
file: Any = ...
|
file: Any = ...
|
||||||
@property
|
@property
|
||||||
@@ -33,7 +33,7 @@ class FileDescriptor:
|
|||||||
_T = TypeVar("_T", bound="Field")
|
_T = TypeVar("_T", bound="Field")
|
||||||
|
|
||||||
class FileField(Field):
|
class FileField(Field):
|
||||||
storage: Union[Storage, Callable[[], Storage]] = ...
|
storage: Storage = ...
|
||||||
upload_to: Union[str, Callable] = ...
|
upload_to: Union[str, Callable] = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in New Issue
Block a user