diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2017-09-25 15:18:29 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-09-25 09:18:44 -0400 |
| commit | c67dce911e513b617adf1329fcd168ae96385fd5 (patch) | |
| tree | 298eddd8dfd43c925143c5ca26ec4cc1bf78bb7d | |
| parent | e241b4e7970e45c21d14df30ce9f6f02b9b7cdce (diff) | |
[2.0.x] Merged startswith() calls.
Backport of 00709d704ee75ace99c4a81aa60e029caeeac387 from master
| -rw-r--r-- | django/template/loader_tags.py | 2 | ||||
| -rw-r--r-- | django/urls/resolvers.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index 6cc8dfc8e3..88c1757b79 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -246,7 +246,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 diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py index 9ee96d38d1..4cd25ff075 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -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 " |
