Skip to content
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

Fix classonlymethod decorator declaration #1494

Merged
merged 1 commit into from
May 13, 2023
Merged
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
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