From 11c3f8cd11a33a4e16ab207bb835285de5d7ed29 Mon Sep 17 00:00:00 2001 From: Maksim Kurnikov Date: Tue, 19 Jan 2021 22:16:12 +0300 Subject: [PATCH] add django 3.1 classproperty --- django-stubs/utils/decorators.pyi | 8 ++------ django-stubs/utils/functional.pyi | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/django-stubs/utils/decorators.pyi b/django-stubs/utils/decorators.pyi index 3badf23..704213d 100644 --- a/django-stubs/utils/decorators.pyi +++ b/django-stubs/utils/decorators.pyi @@ -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): ... @@ -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: ... diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 7fa7aba..954e23d 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -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: ...