Skip to content

Commit d920683

Browse files
committed
Use inline if
1 parent 7bb5fd2 commit d920683

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

rest_framework/decorators.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def api_view(http_method_names=None):
1818
Decorator that converts a function-based view into an APIView subclass.
1919
Takes a list of allowed methods for the view as an argument.
2020
"""
21-
if http_method_names is None:
22-
http_method_names = ['GET']
21+
http_method_names = ['GET'] if http_method_names is None else http_method_names
2322

2423
def decorator(func):
2524

@@ -113,8 +112,8 @@ def detail_route(methods=None, **kwargs):
113112
"""
114113
Used to mark a method on a ViewSet that should be routed for detail requests.
115114
"""
116-
if methods is None:
117-
methods = ['get']
115+
methods = ['get'] if methods is None else methods
116+
118117
def decorator(func):
119118
func.bind_to_methods = methods
120119
func.detail = True
@@ -127,8 +126,8 @@ def list_route(methods=None, **kwargs):
127126
"""
128127
Used to mark a method on a ViewSet that should be routed for list requests.
129128
"""
130-
if methods is None:
131-
methods = ['get']
129+
methods = ['get'] if methods is None else methods
130+
132131
def decorator(func):
133132
func.bind_to_methods = methods
134133
func.detail = False

0 commit comments

Comments
 (0)