Skip to content

Commit

Permalink
Add "deconstruct" methods for all "@deconstructible" classes
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhelba committed Sep 7, 2023
1 parent 7ffaed3 commit 37240df
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 46 deletions.
2 changes: 2 additions & 0 deletions django-stubs/contrib/gis/geos/geometry.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Sequence
from typing import Any

from django.contrib.gis.gdal import CoordTransform, SpatialReference
Expand Down Expand Up @@ -143,3 +144,4 @@ class LinearGeometryMixin:

class GEOSGeometry(GEOSGeometryBase, ListMixin):
def __init__(self, geo_input: Any, srid: int | None = ...) -> None: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
3 changes: 2 additions & 1 deletion django-stubs/contrib/postgres/validators.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Iterable, Mapping
from collections.abc import Iterable, Mapping, Sequence
from typing import Any

from django.core.validators import MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator
Expand All @@ -11,6 +11,7 @@ class KeysValidator:
strict: bool
def __init__(self, keys: Iterable[str], strict: bool = ..., messages: Mapping[str, str] | None = ...) -> None: ...
def __call__(self, value: Any) -> None: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ... # fake

class RangeMaxValueValidator(MaxValueValidator): ...
class RangeMinValueValidator(MinValueValidator): ...
4 changes: 4 additions & 0 deletions django-stubs/core/files/storage/filesystem.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from collections.abc import Sequence
from typing import Any

from django.utils._os import _PathCompatible

from .base import Storage
Expand All @@ -23,3 +26,4 @@ class FileSystemStorage(Storage, StorageSettingsMixin):
def file_permissions_mode(self) -> int | None: ...
@property
def directory_permissions_mode(self) -> int | None: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ... # fake
4 changes: 4 additions & 0 deletions django-stubs/core/files/storage/memory.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from collections.abc import Sequence
from typing import Any

from django.utils._os import _PathCompatible

from .base import Storage
Expand All @@ -21,3 +24,4 @@ class InMemoryStorage(Storage, StorageSettingsMixin):
def file_permissions_mode(self) -> int | None: ...
@property
def directory_permissions_mode(self) -> int | None: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ... # fake
6 changes: 6 additions & 0 deletions django-stubs/core/validators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RegexValidator:
flags: RegexFlag | None = ...,
) -> None: ...
def __call__(self, value: Any) -> None: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class URLValidator(RegexValidator):
ul: str
Expand Down Expand Up @@ -61,6 +62,7 @@ class EmailValidator:
def __call__(self, value: str | None) -> None: ...
def validate_domain_part(self, domain_part: str) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

validate_email: EmailValidator
slug_re: Pattern[str]
Expand Down Expand Up @@ -91,6 +93,7 @@ class BaseValidator:
def compare(self, a: Any, b: Any) -> bool: ...
def clean(self, x: Any) -> Any: ...
def __eq__(self, other: object) -> bool: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class MaxValueValidator(BaseValidator): ...
class MinValueValidator(BaseValidator): ...
Expand All @@ -109,6 +112,7 @@ class DecimalValidator:
def __init__(self, max_digits: int | None, decimal_places: int | None) -> None: ...
def __call__(self, value: Decimal) -> None: ...
def __eq__(self, other: object) -> bool: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class FileExtensionValidator:
message: _StrOrPromise
Expand All @@ -121,6 +125,7 @@ class FileExtensionValidator:
code: str | None = ...,
) -> None: ...
def __call__(self, value: File) -> None: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

def get_available_image_extensions() -> Sequence[str]: ...
def validate_image_file_extension(value: File) -> None: ...
Expand All @@ -130,3 +135,4 @@ class ProhibitNullCharactersValidator:
code: str
def __init__(self, message: _StrOrPromise | None = ..., code: str | None = ...) -> None: ...
def __call__(self, value: Any) -> None: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
3 changes: 3 additions & 0 deletions django-stubs/db/models/expressions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class BaseExpression:
def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ...

class Expression(BaseExpression, Combinable): ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class CombinedExpression(SQLiteNumericMixin, Expression):
connector: str
Expand Down Expand Up @@ -148,6 +149,7 @@ class F(Combinable):
nulls_last: bool | None = ...,
) -> OrderBy: ...
def copy(self) -> F: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class ResolvedOuterRef(F):
contains_aggregate: ClassVar[bool]
Expand Down Expand Up @@ -177,6 +179,7 @@ class Func(SQLiteNumericMixin, Expression):
arg_joiner: str | None = ...,
**extra_context: Any,
) -> _AsSqlType: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class Value(Expression):
value: Any
Expand Down
45 changes: 0 additions & 45 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ django.contrib.auth.password_validation.exceeds_maximum_length_ratio
django.contrib.auth.tokens.PasswordResetTokenGenerator._make_token_with_timestamp
django.contrib.auth.tokens.PasswordResetTokenGenerator.algorithm
django.contrib.auth.validators.ASCIIUsernameValidator.__new__
django.contrib.auth.validators.ASCIIUsernameValidator.deconstruct
django.contrib.auth.validators.UnicodeUsernameValidator.__new__
django.contrib.auth.validators.UnicodeUsernameValidator.deconstruct
django.contrib.auth.views.INTERNAL_RESET_URL_TOKEN
django.contrib.auth.views.LoginView.form_class
django.contrib.auth.views.LogoutView.get_next_page
Expand Down Expand Up @@ -331,7 +329,6 @@ django.contrib.gis.db.models.BinaryField.get_placeholder
django.contrib.gis.db.models.BooleanField.formfield
django.contrib.gis.db.models.Case.__new__
django.contrib.gis.db.models.Case.as_sql
django.contrib.gis.db.models.Case.deconstruct
django.contrib.gis.db.models.CharField.cast_db_type
django.contrib.gis.db.models.CharField.description
django.contrib.gis.db.models.CharField.formfield
Expand All @@ -358,14 +355,11 @@ django.contrib.gis.db.models.Empty
django.contrib.gis.db.models.Exists.empty_result_set_value
django.contrib.gis.db.models.Exists.select_format
django.contrib.gis.db.models.Expression.__new__
django.contrib.gis.db.models.Expression.deconstruct
django.contrib.gis.db.models.Expression.identity
django.contrib.gis.db.models.ExpressionWrapper.__new__
django.contrib.gis.db.models.ExpressionWrapper.deconstruct
django.contrib.gis.db.models.Extent.is_extent
django.contrib.gis.db.models.Extent3D.is_extent
django.contrib.gis.db.models.F.__new__
django.contrib.gis.db.models.F.deconstruct
django.contrib.gis.db.models.Field.__copy__
django.contrib.gis.db.models.Field.__deepcopy__
django.contrib.gis.db.models.Field.__ge__
Expand Down Expand Up @@ -447,7 +441,6 @@ django.contrib.gis.db.models.ForeignObjectRel.one_to_one
django.contrib.gis.db.models.ForeignObjectRel.path_infos
django.contrib.gis.db.models.ForeignObjectRel.related_model
django.contrib.gis.db.models.Func.__new__
django.contrib.gis.db.models.Func.deconstruct
django.contrib.gis.db.models.Func.function
django.contrib.gis.db.models.GenericIPAddressField.formfield
django.contrib.gis.db.models.GeoAggregate
Expand Down Expand Up @@ -499,7 +492,6 @@ django.contrib.gis.db.models.OneToOneRel.__init__
django.contrib.gis.db.models.OrderBy.__new__
django.contrib.gis.db.models.OrderBy.as_oracle
django.contrib.gis.db.models.OrderBy.as_sql
django.contrib.gis.db.models.OrderBy.deconstruct
django.contrib.gis.db.models.PositiveBigIntegerField.formfield
django.contrib.gis.db.models.PositiveBigIntegerField.integer_field_class
django.contrib.gis.db.models.PositiveIntegerField.formfield
Expand Down Expand Up @@ -546,13 +538,11 @@ django.contrib.gis.db.models.UniqueConstraint.__init__
django.contrib.gis.db.models.UniqueConstraint.contains_expressions
django.contrib.gis.db.models.UniqueConstraint.validate
django.contrib.gis.db.models.Value.__new__
django.contrib.gis.db.models.Value.deconstruct
django.contrib.gis.db.models.Value.empty_result_set_value
django.contrib.gis.db.models.Value.for_save
django.contrib.gis.db.models.Variance.__init__
django.contrib.gis.db.models.When.__new__
django.contrib.gis.db.models.When.as_sql
django.contrib.gis.db.models.When.deconstruct
django.contrib.gis.db.models.Window.as_sql
django.contrib.gis.db.models.Window.as_sqlite
django.contrib.gis.db.models.aggregates.Extent.is_extent
Expand Down Expand Up @@ -657,10 +647,8 @@ django.contrib.gis.geometry.hex_regex
django.contrib.gis.geometry.json_regex
django.contrib.gis.geometry.wkt_regex
django.contrib.gis.geos.GEOSGeometry.__new__
django.contrib.gis.geos.GEOSGeometry.deconstruct
django.contrib.gis.geos.Point.tuple
django.contrib.gis.geos.geometry.GEOSGeometry.__new__
django.contrib.gis.geos.geometry.GEOSGeometry.deconstruct
django.contrib.gis.geos.geometry.GEOSGeometryBase.geojson
django.contrib.gis.geos.geometry.GEOSGeometryBase.make_valid
django.contrib.gis.geos.geometry.GEOSGeometryBase.normalize
Expand Down Expand Up @@ -795,7 +783,6 @@ django.contrib.postgres.search.SearchVectorExact.process_rhs
django.contrib.postgres.search.SearchVectorField.class_lookups
django.contrib.postgres.signals.get_type_oids
django.contrib.postgres.validators.KeysValidator.__new__
django.contrib.postgres.validators.KeysValidator.deconstruct
django.contrib.redirects.admin.RedirectAdmin
django.contrib.redirects.models.Redirect.id
django.contrib.redirects.models.Redirect.new_path
Expand Down Expand Up @@ -863,30 +850,26 @@ django.core.files.locks.ULONG_PTR
django.core.files.storage.FileSystemStorage.__new__
django.core.files.storage.FileSystemStorage.base_location
django.core.files.storage.FileSystemStorage.base_url
django.core.files.storage.FileSystemStorage.deconstruct
django.core.files.storage.FileSystemStorage.directory_permissions_mode
django.core.files.storage.FileSystemStorage.file_permissions_mode
django.core.files.storage.FileSystemStorage.location
django.core.files.storage.InMemoryStorage.__new__
django.core.files.storage.InMemoryStorage.base_location
django.core.files.storage.InMemoryStorage.base_url
django.core.files.storage.InMemoryStorage.deconstruct
django.core.files.storage.InMemoryStorage.directory_permissions_mode
django.core.files.storage.InMemoryStorage.file_permissions_mode
django.core.files.storage.InMemoryStorage.location
django.core.files.storage.StorageHandler.backends
django.core.files.storage.filesystem.FileSystemStorage.__new__
django.core.files.storage.filesystem.FileSystemStorage.base_location
django.core.files.storage.filesystem.FileSystemStorage.base_url
django.core.files.storage.filesystem.FileSystemStorage.deconstruct
django.core.files.storage.filesystem.FileSystemStorage.directory_permissions_mode
django.core.files.storage.filesystem.FileSystemStorage.file_permissions_mode
django.core.files.storage.filesystem.FileSystemStorage.location
django.core.files.storage.handler.StorageHandler.backends
django.core.files.storage.memory.InMemoryStorage.__new__
django.core.files.storage.memory.InMemoryStorage.base_location
django.core.files.storage.memory.InMemoryStorage.base_url
django.core.files.storage.memory.InMemoryStorage.deconstruct
django.core.files.storage.memory.InMemoryStorage.directory_permissions_mode
django.core.files.storage.memory.InMemoryStorage.file_permissions_mode
django.core.files.storage.memory.InMemoryStorage.location
Expand Down Expand Up @@ -1022,32 +1005,20 @@ django.core.signing.b62_decode
django.core.signing.b62_encode
django.core.signing.loads
django.core.validators.BaseValidator.__new__
django.core.validators.BaseValidator.deconstruct
django.core.validators.DecimalValidator.__new__
django.core.validators.DecimalValidator.deconstruct
django.core.validators.EmailValidator.__new__
django.core.validators.EmailValidator.deconstruct
django.core.validators.EmailValidator.domain_regex
django.core.validators.EmailValidator.literal_regex
django.core.validators.EmailValidator.user_regex
django.core.validators.FileExtensionValidator.__new__
django.core.validators.FileExtensionValidator.deconstruct
django.core.validators.MaxLengthValidator.__new__
django.core.validators.MaxLengthValidator.deconstruct
django.core.validators.MaxValueValidator.__new__
django.core.validators.MaxValueValidator.deconstruct
django.core.validators.MinLengthValidator.__new__
django.core.validators.MinLengthValidator.deconstruct
django.core.validators.MinValueValidator.__new__
django.core.validators.MinValueValidator.deconstruct
django.core.validators.ProhibitNullCharactersValidator.__new__
django.core.validators.ProhibitNullCharactersValidator.deconstruct
django.core.validators.RegexValidator.__new__
django.core.validators.RegexValidator.deconstruct
django.core.validators.StepValueValidator.__new__
django.core.validators.StepValueValidator.deconstruct
django.core.validators.URLValidator.__new__
django.core.validators.URLValidator.deconstruct
django.core.validators.URLValidator.regex
django.core.validators.URLValidator.unsafe_chars
django.core.validators.URLValidator.max_length
Expand Down Expand Up @@ -1266,7 +1237,6 @@ django.db.models.BinaryField.get_placeholder
django.db.models.BooleanField.formfield
django.db.models.Case.__new__
django.db.models.Case.as_sql
django.db.models.Case.deconstruct
django.db.models.CharField.cast_db_type
django.db.models.CharField.description
django.db.models.CharField.formfield
Expand All @@ -1293,12 +1263,9 @@ django.db.models.Empty
django.db.models.Exists.empty_result_set_value
django.db.models.Exists.select_format
django.db.models.Expression.__new__
django.db.models.Expression.deconstruct
django.db.models.Expression.identity
django.db.models.ExpressionWrapper.__new__
django.db.models.ExpressionWrapper.deconstruct
django.db.models.F.__new__
django.db.models.F.deconstruct
django.db.models.Field.__copy__
django.db.models.Field.__deepcopy__
django.db.models.Field.__ge__
Expand Down Expand Up @@ -1380,7 +1347,6 @@ django.db.models.ForeignObjectRel.one_to_one
django.db.models.ForeignObjectRel.path_infos
django.db.models.ForeignObjectRel.related_model
django.db.models.Func.__new__
django.db.models.Func.deconstruct
django.db.models.Func.function
django.db.models.GenericIPAddressField.formfield
django.db.models.ImageField.__get__
Expand Down Expand Up @@ -1430,7 +1396,6 @@ django.db.models.OneToOneRel.__init__
django.db.models.OrderBy.__new__
django.db.models.OrderBy.as_oracle
django.db.models.OrderBy.as_sql
django.db.models.OrderBy.deconstruct
django.db.models.PositiveBigIntegerField.formfield
django.db.models.PositiveBigIntegerField.integer_field_class
django.db.models.PositiveIntegerField.formfield
Expand Down Expand Up @@ -1476,13 +1441,11 @@ django.db.models.UniqueConstraint.__init__
django.db.models.UniqueConstraint.contains_expressions
django.db.models.UniqueConstraint.validate
django.db.models.Value.__new__
django.db.models.Value.deconstruct
django.db.models.Value.empty_result_set_value
django.db.models.Value.for_save
django.db.models.Variance.__init__
django.db.models.When.__new__
django.db.models.When.as_sql
django.db.models.When.deconstruct
django.db.models.Window.as_sql
django.db.models.Window.as_sqlite
django.db.models.aggregates.Aggregate.__init__
Expand Down Expand Up @@ -1533,25 +1496,19 @@ django.db.models.expressions.BaseExpression.replace_expressions
django.db.models.expressions.BaseExpression.select_format
django.db.models.expressions.Case.__new__
django.db.models.expressions.Case.as_sql
django.db.models.expressions.Case.deconstruct
django.db.models.expressions.Col.relabeled_clone
django.db.models.expressions.Exists.empty_result_set_value
django.db.models.expressions.Exists.select_format
django.db.models.expressions.Expression.__new__
django.db.models.expressions.Expression.deconstruct
django.db.models.expressions.Expression.identity
django.db.models.expressions.ExpressionWrapper.__new__
django.db.models.expressions.ExpressionWrapper.deconstruct
django.db.models.expressions.F.__new__
django.db.models.expressions.F.deconstruct
django.db.models.expressions.Func.__new__
django.db.models.expressions.Func.deconstruct
django.db.models.expressions.Func.function
django.db.models.expressions.NegatedExpression.select_format
django.db.models.expressions.OrderBy.__new__
django.db.models.expressions.OrderBy.as_oracle
django.db.models.expressions.OrderBy.as_sql
django.db.models.expressions.OrderBy.deconstruct
django.db.models.expressions.Ref.get_refs
django.db.models.expressions.Ref.relabeled_clone
django.db.models.expressions.ResolvedOuterRef.as_sql
Expand All @@ -1563,12 +1520,10 @@ django.db.models.expressions.Subquery.external_aliases
django.db.models.expressions.Subquery.get_external_cols
django.db.models.expressions.Subquery.subquery
django.db.models.expressions.Value.__new__
django.db.models.expressions.Value.deconstruct
django.db.models.expressions.Value.empty_result_set_value
django.db.models.expressions.Value.for_save
django.db.models.expressions.When.__new__
django.db.models.expressions.When.as_sql
django.db.models.expressions.When.deconstruct
django.db.models.expressions.Window.as_sql
django.db.models.expressions.Window.as_sqlite
django.db.models.expressions.connector
Expand Down

0 comments on commit 37240df

Please sign in to comment.