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

Annotate return value of all "deconstruct" methods #1695

Merged
merged 5 commits into from
Sep 8, 2023
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
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]]: ...
2 changes: 1 addition & 1 deletion django-stubs/db/models/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BaseConstraint:
def constraint_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ...
def create_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ...
def remove_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ...
def deconstruct(self) -> Any: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
def clone(self) -> Self: ...

class CheckConstraint(BaseConstraint):
Expand Down
11 changes: 9 additions & 2 deletions django-stubs/db/models/expressions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ class BaseExpression:
def reverse_ordering(self) -> BaseExpression: ...
def flatten(self) -> Iterator[BaseExpression]: ...
def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ...
def deconstruct(self) -> Any: ... # fake

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 @@ -149,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 @@ -178,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 @@ -210,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 @@ -220,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 @@ -230,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 @@ -255,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
3 changes: 2 additions & 1 deletion django-stubs/db/models/fields/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
# non-Model instances
@overload
def __get__(self, instance: Any, owner: Any) -> Self: ...
def deconstruct(self) -> Any: ...
def deconstruct(self) -> tuple[str, str, Sequence[Any], dict[str, Any]]: ...
def set_attributes_from_name(self, name: str) -> None: ...
def db_type_parameters(self, connection: BaseDatabaseWrapper) -> DictWrapper: ...
def db_check(self, connection: BaseDatabaseWrapper) -> str | None: ...
Expand Down Expand Up @@ -603,6 +603,7 @@ class DurationField(Field[_ST, _GT]):

class AutoFieldMixin:
db_returning: bool
def deconstruct(self) -> tuple[str, str, Sequence[Any], dict[str, Any]]: ...

class AutoFieldMeta(type): ...

Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/indexes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Index:
self, model: type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ..., **kwargs: Any
) -> Statement: ...
def remove_sql(self, model: type[Model], schema_editor: BaseDatabaseSchemaEditor, **kwargs: Any) -> str: ...
def deconstruct(self) -> Any: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
def clone(self) -> Index: ...
def set_name_with_model(self, model: type[Model]) -> None: ...

Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/manager.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BaseManager(Generic[_T]):
def __init__(self) -> None: ...
def deconstruct(
self,
) -> tuple[bool, str | None, str | None, tuple[Any, ...] | None, dict[str, Any] | None]: ...
) -> tuple[bool, str | None, str | None, Sequence[Any] | None, dict[str, Any] | None]: ...
def check(self, **kwargs: Any) -> list[Any]: ...
@classmethod
def from_queryset(cls, queryset_class: type[QuerySet[_T]], class_name: str | None = ...) -> type[Self]: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/query_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Q(tree.Node):
summarize: bool = ...,
for_save: bool = ...,
) -> WhereNode: ...
def deconstruct(self) -> tuple[str, tuple, dict[str, str]]: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...

class DeferredAttribute:
field: Field
Expand Down
1 change: 0 additions & 1 deletion django-stubs/forms/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class Field:
def widget_attrs(self, widget: Widget) -> dict[str, Any]: ...
def has_changed(self, initial: Any | None, data: Any | None) -> bool: ...
def get_bound_field(self, form: BaseForm, field_name: str) -> BoundField: ...
def deconstruct(self) -> Any: ...

class CharField(Field):
max_length: int | None
Expand Down
Loading