From 7c87c720adf27dc6024acef611e16ae9b567aa43 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Tue, 19 Oct 2021 07:40:17 -0400 Subject: [PATCH] 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: https://github.com/django/django/blob/f5802a21c401b92764a9f3e2886144f3c5d77573/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: https://github.com/django/django/blob/f5802a21c401b92764a9f3e2886144f3c5d77573/django/db/models/fields/files.py#L21 --- django-stubs/db/models/fields/files.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index db6505b..3f8cda5 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -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,