Skip to content

Commit

Permalink
Fix classonlymethod decorator declaration (#1494)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz authored May 13, 2023
1 parent 1efe9c6 commit aa86ca7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django-stubs/utils/decorators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from django.views.generic.base import View
_T = TypeVar("_T", bound=View | Callable) # Any callable
_CallableType = TypeVar("_CallableType", bound=Callable)

class classonlymethod(classmethod): ...
classonlymethod = classmethod

def method_decorator(decorator: Callable | Iterable[Callable], name: str = ...) -> Callable[[_T], _T]: ...
def decorator_from_middleware_with_args(middleware_class: type) -> Callable: ...
Expand Down
10 changes: 10 additions & 0 deletions tests/typecheck/utils/test_decorators.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
- case: classonlymethod
main: |
from django.utils.decorators import classonlymethod
class Bananaman:
@classonlymethod
def count_bananas(cls) -> int:
return 12
reveal_type(Bananaman.count_bananas) # N: Revealed type is "def () -> builtins.int"
- case: method_decorator_class
main: |
from django.views.generic.base import View
Expand Down

0 comments on commit aa86ca7

Please sign in to comment.