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 8, 2023
1 parent f8f1551 commit ef41c00
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 52 deletions.
10 changes: 8 additions & 2 deletions django-stubs/contrib/auth/validators.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from collections.abc import Sequence
from typing import Any

from django.core.validators import RegexValidator

class ASCIIUsernameValidator(RegexValidator): ...
class UnicodeUsernameValidator(RegexValidator): ...
class ASCIIUsernameValidator(RegexValidator):
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class UnicodeUsernameValidator(RegexValidator):
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
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(obj) -> 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(obj) -> 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(obj) -> 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(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ... # fake
20 changes: 17 additions & 3 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(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class URLValidator(RegexValidator):
ul: str
Expand All @@ -40,6 +41,7 @@ class URLValidator(RegexValidator):
schemes: Sequence[str]
def __init__(self, schemes: Sequence[str] | None = ..., **kwargs: Any) -> None: ...
def __call__(self, value: str) -> None: ...
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

integer_validator: RegexValidator

Expand All @@ -61,6 +63,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(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

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

class MaxValueValidator(BaseValidator): ...
class MinValueValidator(BaseValidator): ...
class StepValueValidator(BaseValidator): ...
class MaxValueValidator(BaseValidator):
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class MinValueValidator(BaseValidator):
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class StepValueValidator(BaseValidator):
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class MinLengthValidator(BaseValidator):
def clean(self, x: Sized) -> int: ...
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class MaxLengthValidator(BaseValidator):
def clean(self, x: Sized) -> int: ...
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class DecimalValidator:
messages: dict[str, str]
Expand All @@ -109,6 +120,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(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class FileExtensionValidator:
message: _StrOrPromise
Expand All @@ -121,6 +133,7 @@ class FileExtensionValidator:
code: str | None = ...,
) -> None: ...
def __call__(self, value: File) -> None: ...
def deconstruct(obj) -> 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 +143,4 @@ class ProhibitNullCharactersValidator:
code: str
def __init__(self, message: _StrOrPromise | None = ..., code: str | None = ...) -> None: ...
def __call__(self, value: Any) -> None: ...
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
10 changes: 9 additions & 1 deletion django-stubs/db/models/expressions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class BaseExpression:
def flatten(self) -> Iterator[BaseExpression]: ...
def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ...

class Expression(BaseExpression, Combinable): ...
class Expression(BaseExpression, Combinable):
def deconstruct(obj) -> 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(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

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

class Value(Expression):
value: Any
def __init__(self, value: Any, output_field: Field | None = ...) -> None: ...
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class RawSQL(Expression):
params: list[Any]
Expand Down Expand Up @@ -209,6 +213,7 @@ _E = TypeVar("_E", bound=Q | Combinable)
class ExpressionWrapper(Expression, Generic[_E]):
def __init__(self, expression: _E, output_field: Field) -> None: ...
expression: _E
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class NegatedExpression(ExpressionWrapper[_E]):
def __init__(self, expression: _E) -> None: ...
Expand All @@ -219,6 +224,7 @@ class When(Expression):
condition: Any
result: Any
def __init__(self, condition: Any = ..., then: Any = ..., **lookups: Any) -> None: ...
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class Case(Expression):
template: str
Expand All @@ -229,6 +235,7 @@ class Case(Expression):
def __init__(
self, *cases: Any, default: Any | None = ..., output_field: Field | None = ..., **extra: Any
) -> None: ...
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class Subquery(BaseExpression, Combinable):
template: str
Expand All @@ -254,6 +261,7 @@ class OrderBy(Expression):
) -> None: ...
def asc(self) -> None: ... # type: ignore[override]
def desc(self) -> None: ... # type: ignore[override]
def deconstruct(obj) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class Window(SQLiteNumericMixin, Expression):
template: str
Expand Down
Loading

0 comments on commit ef41c00

Please sign in to comment.