Skip to content

@classproperty decorator has moved in Django 3.1 #451

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

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 6 additions & 1 deletion django-stubs/forms/forms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 8 additions & 6 deletions django-stubs/utils/decorators.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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: ...
22 changes: 21 additions & 1 deletion django-stubs/utils/functional.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
Expand Down Expand Up @@ -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: ...