Skip to content

Commit c6bbf50

Browse files
author
Marc
committed
Fixing flake8 issues after PR #1
1 parent eedcae5 commit c6bbf50

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: rest_framework_docs/api_endpoint.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ def __get_path__(self, parent_pattern):
4747

4848
def __get_allowed_methods__(self):
4949
callback_cls = self.callback.cls
50-
return sorted(
51-
[force_str(m).upper() for m in callback_cls.http_method_names
52-
if hasattr(callback_cls, m) or (issubclass(callback_cls, ModelViewSet)
53-
and m in VIEWSET_METHODS.get(self.callback.suffix, ''))])
50+
51+
def is_method_allowed(method_name):
52+
return hasattr(callback_cls, method_name) or (
53+
issubclass(callback_cls, ModelViewSet) and
54+
method_name in VIEWSET_METHODS.get(self.callback.suffix, []))
55+
56+
return sorted([force_str(name).upper() for name in callback_cls.http_method_names if is_method_allowed(name)])
5457

5558
def __get_docstring__(self):
5659
return inspect.getdoc(self.callback)

0 commit comments

Comments
 (0)