Merge pull request #558 from mkurnikov/jsonfield

Missing Django 3.1 items
This commit is contained in:
Maksim Kurnikov
2021-01-20 00:10:24 +03:00
committed by GitHub
5 changed files with 29 additions and 88 deletions
+1
View File
@@ -60,6 +60,7 @@ from .fields.files import (
FileDescriptor as FileDescriptor, FileDescriptor as FileDescriptor,
) )
from .fields.proxy import OrderWrt as OrderWrt from .fields.proxy import OrderWrt as OrderWrt
from .fields.json import JSONField as JSONField
from .deletion import ( from .deletion import (
CASCADE as CASCADE, CASCADE as CASCADE,
+19 -81
View File
@@ -2,103 +2,43 @@ from . import Field
from .mixins import CheckFieldDefaultMixin from .mixins import CheckFieldDefaultMixin
from django.db.models import lookups from django.db.models import lookups
from django.db.models.lookups import PostgresOperatorLookup, Transform from django.db.models.lookups import PostgresOperatorLookup, Transform
from typing import Any, Optional from typing import Any, Optional, Callable
class JSONField(CheckFieldDefaultMixin, Field): class JSONField(CheckFieldDefaultMixin, Field):
empty_strings_allowed: bool = ...
description: Any = ...
default_error_messages: Any = ...
encoder: Any = ...
decoder: Any = ...
def __init__( def __init__(
self, self,
verbose_name: Optional[Any] = ..., verbose_name: Optional[str] = ...,
name: Optional[Any] = ..., name: Optional[str] = ...,
encoder: Optional[Any] = ..., encoder: Optional[Callable] = ...,
decoder: Optional[Any] = ..., decoder: Optional[Callable] = ...,
**kwargs: Any **kwargs: Any
) -> None: ... ) -> None: ...
def check(self, **kwargs: Any): ...
def deconstruct(self): ...
def from_db_value(self, value: Any, expression: Any, connection: Any): ...
def get_internal_type(self): ...
def get_prep_value(self, value: Any): ...
def get_transform(self, name: Any): ...
def validate(self, value: Any, model_instance: Any) -> None: ...
def value_to_string(self, obj: Any): ... def value_to_string(self, obj: Any): ...
def formfield(self, **kwargs: Any): ...
class DataContains(PostgresOperatorLookup): class DataContains(PostgresOperatorLookup): ...
lookup_name: str = ... class ContainedBy(PostgresOperatorLookup): ...
postgres_operator: str = ...
def as_sql(self, compiler: Any, connection: Any): ...
class ContainedBy(PostgresOperatorLookup): class HasKeyLookup(PostgresOperatorLookup): ...
lookup_name: str = ... class HasKey(HasKeyLookup): ...
postgres_operator: str = ... class HasKeys(HasKeyLookup): ...
def as_sql(self, compiler: Any, connection: Any): ... class HasAnyKeys(HasKeys): ...
class JSONExact(lookups.Exact): ...
class HasKeyLookup(PostgresOperatorLookup):
logical_operator: Any = ...
def as_sql(self, compiler: Any, connection: Any, template: Optional[Any] = ...): ...
def as_mysql(self, compiler: Any, connection: Any): ...
def as_oracle(self, compiler: Any, connection: Any): ...
lhs: Any = ...
rhs: Any = ...
def as_postgresql(self, compiler: Any, connection: Any): ...
def as_sqlite(self, compiler: Any, connection: Any): ...
class HasKey(HasKeyLookup):
lookup_name: str = ...
postgres_operator: str = ...
prepare_rhs: bool = ...
class HasKeys(HasKeyLookup):
lookup_name: str = ...
postgres_operator: str = ...
logical_operator: str = ...
def get_prep_lookup(self): ...
class HasAnyKeys(HasKeys):
lookup_name: str = ...
postgres_operator: str = ...
logical_operator: str = ...
class JSONExact(lookups.Exact):
can_use_none_as_rhs: bool = ...
def process_rhs(self, compiler: Any, connection: Any): ...
class KeyTransform(Transform): class KeyTransform(Transform):
postgres_operator: str = ...
postgres_nested_operator: str = ...
key_name: Any = ... key_name: Any = ...
def __init__(self, key_name: Any, *args: Any, **kwargs: Any) -> None: ... def __init__(self, key_name: Any, *args: Any, **kwargs: Any) -> None: ...
def preprocess_lhs(self, compiler: Any, connection: Any, lhs_only: bool = ...): ... def preprocess_lhs(self, compiler: Any, connection: Any, lhs_only: bool = ...): ...
def as_mysql(self, compiler: Any, connection: Any): ...
def as_oracle(self, compiler: Any, connection: Any): ...
def as_postgresql(self, compiler: Any, connection: Any): ...
class KeyTextTransform(KeyTransform):
postgres_operator: str = ...
postgres_nested_operator: str = ...
class KeyTextTransform(KeyTransform): ...
class KeyTransformTextLookupMixin: class KeyTransformTextLookupMixin:
def __init__(self, key_transform: Any, *args: Any, **kwargs: Any) -> None: ... def __init__(self, key_transform: Any, *args: Any, **kwargs: Any) -> None: ...
class CaseInsensitiveMixin: class CaseInsensitiveMixin: ...
def process_rhs(self, compiler: Any, connection: Any): ... class KeyTransformIsNull(lookups.IsNull): ...
class KeyTransformIn(lookups.In): ...
class KeyTransformIsNull(lookups.IsNull):
def as_oracle(self, compiler: Any, connection: Any): ...
def as_sqlite(self, compiler: Any, connection: Any): ...
class KeyTransformIn(lookups.In):
def process_rhs(self, compiler: Any, connection: Any): ...
class KeyTransformExact(JSONExact):
def process_rhs(self, compiler: Any, connection: Any): ...
def as_oracle(self, compiler: Any, connection: Any): ...
class KeyTransformExact(JSONExact): ...
class KeyTransformIExact(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IExact): ... class KeyTransformIExact(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IExact): ...
class KeyTransformIContains(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IContains): ... class KeyTransformIContains(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IContains): ...
class KeyTransformStartsWith(KeyTransformTextLookupMixin, lookups.StartsWith): ... class KeyTransformStartsWith(KeyTransformTextLookupMixin, lookups.StartsWith): ...
@@ -108,9 +48,7 @@ class KeyTransformIEndsWith(CaseInsensitiveMixin, KeyTransformTextLookupMixin, l
class KeyTransformRegex(KeyTransformTextLookupMixin, lookups.Regex): ... class KeyTransformRegex(KeyTransformTextLookupMixin, lookups.Regex): ...
class KeyTransformIRegex(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IRegex): ... class KeyTransformIRegex(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IRegex): ...
class KeyTransformNumericLookupMixin: class KeyTransformNumericLookupMixin: ...
def process_rhs(self, compiler: Any, connection: Any): ...
class KeyTransformLt(KeyTransformNumericLookupMixin, lookups.LessThan): ... class KeyTransformLt(KeyTransformNumericLookupMixin, lookups.LessThan): ...
class KeyTransformLte(KeyTransformNumericLookupMixin, lookups.LessThanOrEqual): ... class KeyTransformLte(KeyTransformNumericLookupMixin, lookups.LessThanOrEqual): ...
class KeyTransformGt(KeyTransformNumericLookupMixin, lookups.GreaterThan): ... class KeyTransformGt(KeyTransformNumericLookupMixin, lookups.GreaterThan): ...
+1 -1
View File
@@ -60,7 +60,7 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
) -> Any: ... ) -> Any: ...
class PostgresOperatorLookup(FieldGetDbPrepValueMixin, Lookup): class PostgresOperatorLookup(FieldGetDbPrepValueMixin, Lookup):
postgres_operator: Any = ... postgres_operator: str = ...
def as_postgresql(self, compiler: Any, connection: Any): ... def as_postgresql(self, compiler: Any, connection: Any): ...
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ... class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ...
+2 -6
View File
@@ -3,6 +3,8 @@ from typing import Any, Callable, Iterable, Optional, Type, Union, TypeVar
from django.utils.deprecation import MiddlewareMixin from django.utils.deprecation import MiddlewareMixin
from django.views.generic.base import View from django.views.generic.base import View
from django.utils.functional import classproperty as classproperty
_T = TypeVar("_T", bound=Union[View, Callable]) # Any callable _T = TypeVar("_T", bound=Union[View, Callable]) # Any callable
class classonlymethod(classmethod): ... class classonlymethod(classmethod): ...
@@ -12,9 +14,3 @@ def decorator_from_middleware_with_args(middleware_class: type) -> Callable: ...
def decorator_from_middleware(middleware_class: type) -> Callable: ... def decorator_from_middleware(middleware_class: type) -> Callable: ...
def available_attrs(fn: Callable): ... def available_attrs(fn: Callable): ...
def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callable: ... def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callable: ...
class classproperty:
fget: Optional[Callable] = ...
def __init__(self, method: Optional[Callable] = ...) -> None: ...
def __get__(self, instance: Any, cls: Optional[type] = ...) -> Any: ...
def getter(self, method: Callable) -> classproperty: ...
+6
View File
@@ -61,3 +61,9 @@ _PartitionMember = TypeVar("_PartitionMember")
def partition( def partition(
predicate: Callable, values: List[_PartitionMember] predicate: Callable, values: List[_PartitionMember]
) -> Tuple[List[_PartitionMember], List[_PartitionMember]]: ... ) -> Tuple[List[_PartitionMember], List[_PartitionMember]]: ...
class classproperty:
fget: Optional[Callable] = ...
def __init__(self, method: Optional[Callable] = ...) -> None: ...
def __get__(self, instance: Any, cls: Optional[type] = ...) -> Any: ...
def getter(self, method: Callable) -> classproperty: ...