Skip to content

Add actions parameter to ViewSetMixin.as_view. #18

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

Merged
merged 2 commits into from
Aug 16, 2019
Merged
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions rest_framework-stubs/viewsets.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import OrderedDict
from typing import Any, Callable, List
from typing import Any, Callable, Dict, List, Optional

from rest_framework.request import Request

Expand All @@ -11,7 +11,7 @@ class ViewSetMixin(object):
basename: str
request: Any
@classmethod
def as_view(cls, **initkwargs: Any) -> Callable: ...
def as_view(cls, actions: Optional[Dict[str, Any]] = None, **initkwargs: Any) -> Callable: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it Optional[Dict[str, str]]?

Why str, str?
Searching trough the docs gave me this impression: https://github.com/encode/django-rest-framework/blob/master/rest_framework/viewsets.py#L6

Can you please point to any other use-cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it seems that it's a mapping between http method and method name on the class, it should be Dict[str, str] or maybe Mapping[str, str] to be a bit more general.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkurnikov Mapping could be unnecessarily broad. IMO the type should be Dict[str, str] unless someone explicitly requests to change it.

def initialize_request(self, request: Request, *args: Any, **kwargs: Any) -> Request: ...
def reverse_action(self, url_name: str, *args: Any, **kwargs: Any) -> str: ...
@classmethod
Expand Down