-
-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Expression classes
output_field
to @cached_property
or `Cl…
…assVar` and improve type (#1769) * Update `BaseExpression.output_field` * Remove allowlist entries rm -rf .mypy_cache/ && bash ./scripts/stubtest.sh | rg "note: unused allowlist entry" | cut -d" " -f5 | xargs -I {} sd "{}\n" "" ./scripts/stubtest/allowlist_todo.txt * Change to ClassVar when necessary Found match using `rg "^ output_field = .*Field\(\)"` in django repository * Update allowlist and remove unused ignore * Fix last occurences and reorder allowlist
- Loading branch information
1 parent
997ac44
commit eda5787
Showing
19 changed files
with
148 additions
and
125 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
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,11 +1,25 @@ | ||
from django.db.models.aggregates import Aggregate | ||
from typing import ClassVar | ||
|
||
from django.contrib.postgres.fields import ArrayField | ||
from django.db.models import Aggregate, BooleanField, JSONField, TextField | ||
|
||
from .mixins import OrderableAggMixin | ||
|
||
class ArrayAgg(OrderableAggMixin, Aggregate): ... | ||
class ArrayAgg(OrderableAggMixin, Aggregate): | ||
@property | ||
def output_field(self) -> ArrayField: ... | ||
|
||
class BitAnd(Aggregate): ... | ||
class BitOr(Aggregate): ... | ||
class BoolAnd(Aggregate): ... | ||
class BoolOr(Aggregate): ... | ||
class JSONBAgg(OrderableAggMixin, Aggregate): ... | ||
class StringAgg(OrderableAggMixin, Aggregate): ... | ||
|
||
class BoolAnd(Aggregate): | ||
output_field: ClassVar[BooleanField] | ||
|
||
class BoolOr(Aggregate): | ||
output_field: ClassVar[BooleanField] | ||
|
||
class JSONBAgg(OrderableAggMixin, Aggregate): | ||
output_field: ClassVar[JSONField] | ||
|
||
class StringAgg(OrderableAggMixin, Aggregate): | ||
output_field: ClassVar[TextField] |
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,23 @@ | ||
from typing import Any | ||
from typing import Any, ClassVar | ||
|
||
from django.db.models import Field, Transform | ||
from django.contrib.postgres.fields.array import ArrayField | ||
from django.db.models import Field, TextField, Transform | ||
from django.db.models.fields.mixins import CheckFieldDefaultMixin | ||
|
||
class HStoreField(CheckFieldDefaultMixin, Field): | ||
def get_transform(self, name: str) -> Any: ... | ||
|
||
class KeyTransform(Transform): | ||
output_field: ClassVar[TextField] | ||
|
||
def __init__(self, key_name: str, *args: Any, **kwargs: Any) -> None: ... | ||
|
||
class KeyTransformFactory: | ||
def __init__(self, key_name: str) -> None: ... | ||
def __call__(self, *args: Any, **kwargs: Any) -> KeyTransform: ... | ||
|
||
class KeysTransform(Transform): ... | ||
class ValuesTransform(Transform): ... | ||
class KeysTransform(Transform): | ||
output_field: ClassVar[ArrayField] | ||
|
||
class ValuesTransform(Transform): | ||
output_field: ClassVar[ArrayField] |
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,4 +1,9 @@ | ||
from django.db.models import Func | ||
from typing import ClassVar | ||
|
||
class RandomUUID(Func): ... | ||
class TransactionNow(Func): ... | ||
from django.db.models import DateTimeField, Func, UUIDField | ||
|
||
class RandomUUID(Func): | ||
output_field: ClassVar[UUIDField] | ||
|
||
class TransactionNow(Func): | ||
output_field: ClassVar[DateTimeField] |
Oops, something went wrong.