-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simulate
@deconstructible
as a mixin class (#1818)
`@desconstructible` inserts its own `__new__` method and adds a `deconstruct` method to decorated classes. We can simulate that behaviour with a class definition, which decorated classes inherits.
- Loading branch information
Showing
9 changed files
with
32 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
from collections.abc import Sequence | ||
from typing import Any | ||
|
||
from django.core.validators import 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]]: ... | ||
class ASCIIUsernameValidator(RegexValidator): ... | ||
class UnicodeUsernameValidator(RegexValidator): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
from collections.abc import Iterable, Mapping, Sequence | ||
from collections.abc import Iterable, Mapping | ||
from typing import Any | ||
|
||
from django.core.validators import MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator | ||
from django.utils.deconstruct import _Deconstructible | ||
|
||
class ArrayMaxLengthValidator(MaxLengthValidator): ... | ||
class ArrayMinLengthValidator(MinLengthValidator): ... | ||
|
||
class KeysValidator: | ||
class KeysValidator(_Deconstructible): | ||
messages: dict[str, str] | ||
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): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.