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:
Brian Helba
2021-10-19 07:40:17 -04:00
committed by GitHub
parent 9938378e94
commit 7c87c720ad

View File

@@ -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.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.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
class FieldFile(File):
instance: Model = ...
field: FileField = ...
storage: FileSystemStorage = ...
storage: Storage = ...
def __init__(self, instance: Model, field: FileField, name: Optional[str]) -> None: ...
file: Any = ...
@property
@@ -33,7 +33,7 @@ class FileDescriptor:
_T = TypeVar("_T", bound="Field")
class FileField(Field):
storage: Union[Storage, Callable[[], Storage]] = ...
storage: Storage = ...
upload_to: Union[str, Callable] = ...
def __init__(
self,