Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing methods and superclass to FieldFile #2051

Merged
merged 6 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ...
mthuurne marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -1417,7 +1417,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
Loading