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

Missing Django 3.1 items #558

Merged
merged 2 commits into from
Jan 19, 2021
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
1 change: 1 addition & 0 deletions django-stubs/db/models/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ from .fields.files import (
FileDescriptor as FileDescriptor,
)
from .fields.proxy import OrderWrt as OrderWrt
from .fields.json import JSONField as JSONField

from .deletion import (
CASCADE as CASCADE,
Expand Down
100 changes: 19 additions & 81 deletions django-stubs/db/models/fields/json.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,103 +2,43 @@ from . import Field
from .mixins import CheckFieldDefaultMixin
from django.db.models import lookups
from django.db.models.lookups import PostgresOperatorLookup, Transform
from typing import Any, Optional
from typing import Any, Optional, Callable


class JSONField(CheckFieldDefaultMixin, Field):
empty_strings_allowed: bool = ...
description: Any = ...
default_error_messages: Any = ...
encoder: Any = ...
decoder: Any = ...
def __init__(
self,
verbose_name: Optional[Any] = ...,
name: Optional[Any] = ...,
encoder: Optional[Any] = ...,
decoder: Optional[Any] = ...,
verbose_name: Optional[str] = ...,
name: Optional[str] = ...,
encoder: Optional[Callable] = ...,
decoder: Optional[Callable] = ...,
**kwargs: Any
) -> 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): ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> str

def formfield(self, **kwargs: Any): ...

class DataContains(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
def as_sql(self, compiler: Any, connection: Any): ...

class ContainedBy(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
def as_sql(self, compiler: Any, connection: Any): ...

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 DataContains(PostgresOperatorLookup): ...
class ContainedBy(PostgresOperatorLookup): ...

class JSONExact(lookups.Exact):
can_use_none_as_rhs: bool = ...
def process_rhs(self, compiler: Any, connection: Any): ...
class HasKeyLookup(PostgresOperatorLookup): ...
class HasKey(HasKeyLookup): ...
class HasKeys(HasKeyLookup): ...
class HasAnyKeys(HasKeys): ...
class JSONExact(lookups.Exact): ...

class KeyTransform(Transform):
postgres_operator: str = ...
postgres_nested_operator: str = ...
key_name: Any = ...
def __init__(self, key_name: Any, *args: Any, **kwargs: Any) -> None: ...
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:
def __init__(self, key_transform: Any, *args: Any, **kwargs: Any) -> None: ...

class CaseInsensitiveMixin:
def process_rhs(self, compiler: Any, connection: Any): ...

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 CaseInsensitiveMixin: ...
class KeyTransformIsNull(lookups.IsNull): ...
class KeyTransformIn(lookups.In): ...

class KeyTransformExact(JSONExact): ...
class KeyTransformIExact(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IExact): ...
class KeyTransformIContains(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IContains): ...
class KeyTransformStartsWith(KeyTransformTextLookupMixin, lookups.StartsWith): ...
Expand All @@ -108,9 +48,7 @@ class KeyTransformIEndsWith(CaseInsensitiveMixin, KeyTransformTextLookupMixin, l
class KeyTransformRegex(KeyTransformTextLookupMixin, lookups.Regex): ...
class KeyTransformIRegex(CaseInsensitiveMixin, KeyTransformTextLookupMixin, lookups.IRegex): ...

class KeyTransformNumericLookupMixin:
def process_rhs(self, compiler: Any, connection: Any): ...

class KeyTransformNumericLookupMixin: ...
class KeyTransformLt(KeyTransformNumericLookupMixin, lookups.LessThan): ...
class KeyTransformLte(KeyTransformNumericLookupMixin, lookups.LessThanOrEqual): ...
class KeyTransformGt(KeyTransformNumericLookupMixin, lookups.GreaterThan): ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/lookups.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
) -> Any: ...

class PostgresOperatorLookup(FieldGetDbPrepValueMixin, Lookup):
postgres_operator: Any = ...
postgres_operator: str = ...
def as_postgresql(self, compiler: Any, connection: Any): ...

class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ...
Expand Down
8 changes: 2 additions & 6 deletions django-stubs/utils/decorators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ from typing import Any, Callable, Iterable, Optional, Type, Union, TypeVar
from django.utils.deprecation import MiddlewareMixin
from django.views.generic.base import View

from django.utils.functional import classproperty as classproperty

_T = TypeVar("_T", bound=Union[View, Callable]) # Any callable

class classonlymethod(classmethod): ...
Expand All @@ -12,9 +14,3 @@ def decorator_from_middleware_with_args(middleware_class: type) -> Callable: ...
def decorator_from_middleware(middleware_class: type) -> Callable: ...
def available_attrs(fn: 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 changes: 6 additions & 0 deletions django-stubs/utils/functional.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ _PartitionMember = TypeVar("_PartitionMember")
def partition(
predicate: Callable, values: 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: ...