Skip to content

Commit 089887d

Browse files
Nifledtomchristie
authored andcommitted
Simplified chained comparisons and minor code fixes (#5276)
1 parent 2a1fd3b commit 089887d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

rest_framework/pagination.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _positive_int(integer_string, strict=False, cutoff=None):
3131
if ret < 0 or (ret == 0 and strict):
3232
raise ValueError()
3333
if cutoff:
34-
ret = min(ret, cutoff)
34+
return min(ret, cutoff)
3535
return ret
3636

3737

@@ -95,7 +95,7 @@ def _get_displayed_page_numbers(current, final):
9595
# Now sort the page numbers and drop anything outside the limits.
9696
included = [
9797
idx for idx in sorted(list(included))
98-
if idx > 0 and idx <= final
98+
if 0 < idx <= final
9999
]
100100

101101
# Finally insert any `...` breaks

rest_framework/status.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010

1111
def is_informational(code):
12-
return code >= 100 and code <= 199
12+
return 100 <= code <= 199
1313

1414

1515
def is_success(code):
16-
return code >= 200 and code <= 299
16+
return 200 <= code <= 299
1717

1818

1919
def is_redirect(code):
20-
return code >= 300 and code <= 399
20+
return 300 <= code <= 399
2121

2222

2323
def is_client_error(code):
24-
return code >= 400 and code <= 499
24+
return 400 <= code <= 499
2525

2626

2727
def is_server_error(code):
28-
return code >= 500 and code <= 599
28+
return 500 <= code <= 599
2929

3030

3131
HTTP_100_CONTINUE = 100

rest_framework/utils/formatting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def camelcase_to_spaces(content):
5252
Translate 'CamelCaseNames' to 'Camel Case Names'.
5353
Used when generating names from view classes.
5454
"""
55-
camelcase_boundry = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'
56-
content = re.sub(camelcase_boundry, ' \\1', content).strip()
55+
camelcase_boundary = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'
56+
content = re.sub(camelcase_boundary, ' \\1', content).strip()
5757
return ' '.join(content.split('_')).title()
5858

5959

0 commit comments

Comments
 (0)