Skip to content

Commit

Permalink
Add missing methods and superclass to FieldFile (#2051)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Sobolev <[email protected]>
  • Loading branch information
mthuurne and sobolevn authored Apr 10, 2024
1 parent b32a7a0 commit 94968c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion django-stubs/db/models/fields/files.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ from django.db.models.base import Model
from django.db.models.expressions import Expression
from django.db.models.fields import NOT_PROVIDED, Field, _ErrorMessagesMapping, _FieldChoices
from django.db.models.query_utils import DeferredAttribute
from django.db.models.utils import AltersData
from django.utils._os import _PathCompatible
from django.utils.functional import _StrOrPromise
from typing_extensions import Self

class FieldFile(File):
class FieldFile(File, AltersData):
instance: Model
field: FileField
storage: Storage
Expand All @@ -31,6 +32,10 @@ class FieldFile(File):
def delete(self, save: bool = ...) -> None: ...
@property
def closed(self) -> bool: ...
def __getstate__(self) -> dict[str, Any]: ...
def __setstate__(self, state: dict[str, Any]) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...

class FileDescriptor(DeferredAttribute):
field: FileField
Expand Down
3 changes: 3 additions & 0 deletions django-stubs/db/models/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ def make_model_tuple(model: type[Model] | str | tuple[str, str]) -> tuple[str, s
def resolve_callables(mapping: MutableMapping[str, Any]) -> Iterator[tuple[str, Any]]: ...
def unpickle_named_row(names: Iterable[str], values: Iterable[Any]) -> NamedTuple: ...
def create_namedtuple_class(*names: str) -> type[NamedTuple]: ...

class AltersData:
def __init_subclass__(cls, **kwargs: Any) -> None: ...
1 change: 0 additions & 1 deletion scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,6 @@ django.db.models.sql.where.WhereNode.set_source_expressions
django.db.models.sql.where.WhereNode.split_having
django.db.models.sql.where.WhereNode.split_having_qualify
django.db.models.sql.where.XOR
django.db.models.utils.AltersData
django.db.utils.ConnectionHandler.configure_settings
django.db.utils.ConnectionHandler.ensure_defaults
django.db.utils.ConnectionHandler.prepare_test_settings
Expand Down

0 comments on commit 94968c8

Please sign in to comment.