-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your contribution!
Just one question from me.
rest_framework-stubs/viewsets.pyi
Outdated
@@ -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: ... |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
rest_framework-stubs/viewsets.pyi
Outdated
@@ -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: ... |
There was a problem hiding this comment.
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.
The ViewSetMixin supports an actions positional parameter.
https://www.django-rest-framework.org/api-guide/viewsets/
https://github.com/encode/django-rest-framework/blob/master/rest_framework/viewsets.py#L49