Merged startswith() calls.

This commit is contained in:
Mariusz Felisiak 2017-09-25 15:18:29 +02:00 committed by Tim Graham
parent 67a6ba391b
commit 00709d704e
2 changed files with 2 additions and 2 deletions

View File

@ -222,7 +222,7 @@ def construct_relative_path(current_template_name, relative_name):
Convert a relative path (starting with './' or '../') to the full template
name based on the current_template_name.
"""
if not any(relative_name.startswith(x) for x in ["'./", "'../", '"./', '"../']):
if not relative_name.startswith(("'./", "'../", '"./', '"../')):
# relative_name is a variable or a literal that doesn't contain a
# relative path.
return relative_name

View File

@ -119,7 +119,7 @@ class CheckURLMixin:
# Skip check as it can be useful to start a URL pattern with a slash
# when APPEND_SLASH=False.
return []
if any(regex_pattern.startswith(x) for x in ('/', '^/', '^\/')) and not regex_pattern.endswith('/'):
if regex_pattern.startswith(('/', '^/', '^\/')) and not regex_pattern.endswith('/'):
warning = Warning(
"Your URL pattern {} has a route beginning with a '/'. Remove this "
"slash as it is unnecessary. If this pattern is targeted in an "