From 93db44bdf26cb836bd5635ade73007de513fdde2 Mon Sep 17 00:00:00 2001 From: Alexander Viklund Date: Thu, 27 Aug 2020 14:38:57 +0200 Subject: [PATCH 1/2] classproperty decorator has moved in django 3.1 --- django-stubs/utils/decorators.pyi | 14 ++++++++------ django-stubs/utils/functional.pyi | 12 +++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/django-stubs/utils/decorators.pyi b/django-stubs/utils/decorators.pyi index 3badf23eb..1000b4481 100644 --- a/django-stubs/utils/decorators.pyi +++ b/django-stubs/utils/decorators.pyi @@ -1,5 +1,6 @@ -from typing import Any, Callable, Iterable, Optional, Type, Union, TypeVar +from typing import Any, Callable, Iterable, Optional, Type, TypeVar, Union +import django from django.utils.deprecation import MiddlewareMixin from django.views.generic.base import View @@ -13,8 +14,9 @@ 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: ... +if django.VERSION < (3, 1): + 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 7fa7abace..af788a7e9 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -1,6 +1,9 @@ -from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, TypeVar, Generic, overload from functools import wraps as wraps # noqa: F401 +from typing import ( + Any, Callable, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload, +) +import django from django.db.models.base import Model def curry(_curried_func: Any, *args: Any, **kwargs: Any): ... @@ -61,3 +64,10 @@ _PartitionMember = TypeVar("_PartitionMember") def partition( predicate: Callable, values: List[_PartitionMember] ) -> Tuple[List[_PartitionMember], List[_PartitionMember]]: ... + +if django.VERSION >= (3, 1): + 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: ... From 033910dc172e8cdfb5e3f9e66716e03fc4623582 Mon Sep 17 00:00:00 2001 From: Alexander Viklund Date: Thu, 27 Aug 2020 14:55:34 +0200 Subject: [PATCH 2/2] Paint it black --- django-stubs/forms/forms.pyi | 7 ++++++- django-stubs/utils/functional.pyi | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/django-stubs/forms/forms.pyi b/django-stubs/forms/forms.pyi index bb7be6baa..dcb140c6c 100644 --- a/django-stubs/forms/forms.pyi +++ b/django-stubs/forms/forms.pyi @@ -70,7 +70,12 @@ class BaseForm: def visible_fields(self): ... def get_initial_for_field(self, field: Field, field_name: str) -> Any: ... def _html_output( - self, normal_row: str, error_row: str, row_ender: str, help_text_html: str, errors_on_separate_row: bool, + self, + normal_row: str, + error_row: str, + row_ender: str, + help_text_html: str, + errors_on_separate_row: bool, ) -> SafeText: ... class Form(BaseForm): diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index af788a7e9..3bbf9cb25 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -1,6 +1,16 @@ from functools import wraps as wraps # noqa: F401 from typing import ( - Any, Callable, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload, + Any, + Callable, + Dict, + Generic, + List, + Optional, + Tuple, + Type, + TypeVar, + Union, + overload, ) import django