Skip to content

Commit f074772

Browse files
authored
Merge pull request #558 from mkurnikov/jsonfield
Missing Django 3.1 items
2 parents 58c087f + 11c3f8c commit f074772

File tree

5 files changed

+29
-88
lines changed

5 files changed

+29
-88
lines changed

django-stubs/db/models/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ from .fields.files import (
6060
FileDescriptor as FileDescriptor,
6161
)
6262
from .fields.proxy import OrderWrt as OrderWrt
63+
from .fields.json import JSONField as JSONField
6364

6465
from .deletion import (
6566
CASCADE as CASCADE,

django-stubs/db/models/fields/json.pyi

Lines changed: 19 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,103 +2,43 @@ from . import Field
22
from .mixins import CheckFieldDefaultMixin
33
from django.db.models import lookups
44
from django.db.models.lookups import PostgresOperatorLookup, Transform
5-
from typing import Any, Optional
5+
from typing import Any, Optional, Callable
6+
67

78
class JSONField(CheckFieldDefaultMixin, Field):
8-
empty_strings_allowed: bool = ...
9-
description: Any = ...
10-
default_error_messages: Any = ...
11-
encoder: Any = ...
12-
decoder: Any = ...
139
def __init__(
1410
self,
15-
verbose_name: Optional[Any] = ...,
16-
name: Optional[Any] = ...,
17-
encoder: Optional[Any] = ...,
18-
decoder: Optional[Any] = ...,
11+
verbose_name: Optional[str] = ...,
12+
name: Optional[str] = ...,
13+
encoder: Optional[Callable] = ...,
14+
decoder: Optional[Callable] = ...,
1915
**kwargs: Any
2016
) -> None: ...
21-
def check(self, **kwargs: Any): ...
22-
def deconstruct(self): ...
23-
def from_db_value(self, value: Any, expression: Any, connection: Any): ...
24-
def get_internal_type(self): ...
25-
def get_prep_value(self, value: Any): ...
26-
def get_transform(self, name: Any): ...
27-
def validate(self, value: Any, model_instance: Any) -> None: ...
2817
def value_to_string(self, obj: Any): ...
29-
def formfield(self, **kwargs: Any): ...
30-
31-
class DataContains(PostgresOperatorLookup):
32-
lookup_name: str = ...
33-
postgres_operator: str = ...
34-
def as_sql(self, compiler: Any, connection: Any): ...
35-
36-
class ContainedBy(PostgresOperatorLookup):
37-
lookup_name: str = ...
38-
postgres_operator: str = ...
39-
def as_sql(self, compiler: Any, connection: Any): ...
40-
41-
class HasKeyLookup(PostgresOperatorLookup):
42-
logical_operator: Any = ...
43-
def as_sql(self, compiler: Any, connection: Any, template: Optional[Any] = ...): ...
44-
def as_mysql(self, compiler: Any, connection: Any): ...
45-
def as_oracle(self, compiler: Any, connection: Any): ...
46-
lhs: Any = ...
47-
rhs: Any = ...
48-
def as_postgresql(self, compiler: Any, connection: Any): ...
49-
def as_sqlite(self, compiler: Any, connection: Any): ...
50-
51-
class HasKey(HasKeyLookup):
52-
lookup_name: str = ...
53-
postgres_operator: str = ...
54-
prepare_rhs: bool = ...
55-
56-
class HasKeys(HasKeyLookup):
57-
lookup_name: str = ...
58-
postgres_operator: str = ...
59-
logical_operator: str = ...
60-
def get_prep_lookup(self): ...
6118

62-
class HasAnyKeys(HasKeys):
63-
lookup_name: str = ...
64-
postgres_operator: str = ...
65-
logical_operator: str = ...
19+
class DataContains(PostgresOperatorLookup): ...
20+
class ContainedBy(PostgresOperatorLookup): ...
6621

67-
class JSONExact(lookups.Exact):
68-
can_use_none_as_rhs: bool = ...
69-
def process_rhs(self, compiler: Any, connection: Any): ...
22+
class HasKeyLookup(PostgresOperatorLookup): ...
23+
class HasKey(HasKeyLookup): ...
24+
class HasKeys(HasKeyLookup): ...
25+
class HasAnyKeys(HasKeys): ...
26+
class JSONExact(lookups.Exact): ...
7027

7128
class KeyTransform(Transform):
72-
postgres_operator: str = ...
73-
postgres_nested_operator: str = ...
7429
key_name: Any = ...
7530
def __init__(self, key_name: Any, *args: Any, **kwargs: Any) -> None: ...
7631
def preprocess_lhs(self, compiler: Any, connection: Any, lhs_only: bool = ...): ...
77-
def as_mysql(self, compiler: Any, connection: Any): ...
78-
def as_oracle(self, compiler: Any, connection: Any): ...
79-
def as_postgresql(self, compiler: Any, connection: Any): ...
80-
81-
class KeyTextTransform(KeyTransform):
82-
postgres_operator: str = ...
83-
postgres_nested_operator: str = ...
8432

33+
class KeyTextTransform(KeyTransform): ...
8534
class KeyTransformTextLookupMixin:
8635
def __init__(self, key_transform: Any, *args: Any, **kwargs: Any) -> None: ...
8736

88-
class CaseInsensitiveMixin:
89-
def process_rhs(self, compiler: Any, connection: Any): ...
90-
91-
class KeyTransformIsNull(lookups.IsNull):
92-
def as_oracle(self, compiler: Any, connection: Any): ...
93-
def as_sqlite(self, compiler: Any, connection: Any): ...
94-
95-
class KeyTransformIn(lookups.In):
96-
def process_rhs(self, compiler: Any, connection: Any): ...
97-
98-
class KeyTransformExact(JSONExact):
99-
def process_rhs(self, compiler: Any, connection: Any): ...
100-
def as_oracle(self, compiler: Any, connection: Any): ...
37+
class CaseInsensitiveMixin: ...
38+
class KeyTransformIsNull(lookups.IsNull): ...
39+
class KeyTransformIn(lookups.In): ...
10140

41+
class KeyTransformExact(JSONExact): ...
10242
class KeyTransformIExact(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IExact): ...
10343
class KeyTransformIContains(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IContains): ...
10444
class KeyTransformStartsWith(KeyTransformTextLookupMixin, lookups.StartsWith): ...
@@ -108,9 +48,7 @@ class KeyTransformIEndsWith(CaseInsensitiveMixin, KeyTransformTextLookupMixin, l
10848
class KeyTransformRegex(KeyTransformTextLookupMixin, lookups.Regex): ...
10949
class KeyTransformIRegex(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IRegex): ...
11050

111-
class KeyTransformNumericLookupMixin:
112-
def process_rhs(self, compiler: Any, connection: Any): ...
113-
51+
class KeyTransformNumericLookupMixin: ...
11452
class KeyTransformLt(KeyTransformNumericLookupMixin, lookups.LessThan): ...
11553
class KeyTransformLte(KeyTransformNumericLookupMixin, lookups.LessThanOrEqual): ...
11654
class KeyTransformGt(KeyTransformNumericLookupMixin, lookups.GreaterThan): ...

django-stubs/db/models/lookups.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
6060
) -> Any: ...
6161

6262
class PostgresOperatorLookup(FieldGetDbPrepValueMixin, Lookup):
63-
postgres_operator: Any = ...
63+
postgres_operator: str = ...
6464
def as_postgresql(self, compiler: Any, connection: Any): ...
6565

6666
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ...

django-stubs/utils/decorators.pyi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ from typing import Any, Callable, Iterable, Optional, Type, Union, TypeVar
33
from django.utils.deprecation import MiddlewareMixin
44
from django.views.generic.base import View
55

6+
from django.utils.functional import classproperty as classproperty
7+
68
_T = TypeVar("_T", bound=Union[View, Callable]) # Any callable
79

810
class classonlymethod(classmethod): ...
@@ -12,9 +14,3 @@ def decorator_from_middleware_with_args(middleware_class: type) -> Callable: ...
1214
def decorator_from_middleware(middleware_class: type) -> Callable: ...
1315
def available_attrs(fn: Callable): ...
1416
def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callable: ...
15-
16-
class classproperty:
17-
fget: Optional[Callable] = ...
18-
def __init__(self, method: Optional[Callable] = ...) -> None: ...
19-
def __get__(self, instance: Any, cls: Optional[type] = ...) -> Any: ...
20-
def getter(self, method: Callable) -> classproperty: ...

django-stubs/utils/functional.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ _PartitionMember = TypeVar("_PartitionMember")
6161
def partition(
6262
predicate: Callable, values: List[_PartitionMember]
6363
) -> Tuple[List[_PartitionMember], List[_PartitionMember]]: ...
64+
65+
class classproperty:
66+
fget: Optional[Callable] = ...
67+
def __init__(self, method: Optional[Callable] = ...) -> None: ...
68+
def __get__(self, instance: Any, cls: Optional[type] = ...) -> Any: ...
69+
def getter(self, method: Callable) -> classproperty: ...

0 commit comments

Comments
 (0)