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/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..3bbf9cb25 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -1,6 +1,19 @@ -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 +74,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: ...