diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-03 20:24:19 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
| commit | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch) | |
| tree | f0506b668a013d0063e5fba3dbf4863b466713ba /django/urls/utils.py | |
| parent | f68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff) | |
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'django/urls/utils.py')
| -rw-r--r-- | django/urls/utils.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/django/urls/utils.py b/django/urls/utils.py index e59ab9fdbd..60b46d9050 100644 --- a/django/urls/utils.py +++ b/django/urls/utils.py @@ -18,11 +18,15 @@ def get_callable(lookup_view): return lookup_view if not isinstance(lookup_view, str): - raise ViewDoesNotExist("'%s' is not a callable or a dot-notation path" % lookup_view) + raise ViewDoesNotExist( + "'%s' is not a callable or a dot-notation path" % lookup_view + ) mod_name, func_name = get_mod_func(lookup_view) if not func_name: # No '.' in lookup_view - raise ImportError("Could not import '%s'. The path must be fully qualified." % lookup_view) + raise ImportError( + "Could not import '%s'. The path must be fully qualified." % lookup_view + ) try: mod = import_module(mod_name) @@ -30,8 +34,8 @@ def get_callable(lookup_view): parentmod, submod = get_mod_func(mod_name) if submod and not module_has_submodule(import_module(parentmod), submod): raise ViewDoesNotExist( - "Could not import '%s'. Parent module %s does not exist." % - (lookup_view, mod_name) + "Could not import '%s'. Parent module %s does not exist." + % (lookup_view, mod_name) ) else: raise @@ -40,14 +44,14 @@ def get_callable(lookup_view): view_func = getattr(mod, func_name) except AttributeError: raise ViewDoesNotExist( - "Could not import '%s'. View does not exist in module %s." % - (lookup_view, mod_name) + "Could not import '%s'. View does not exist in module %s." + % (lookup_view, mod_name) ) else: if not callable(view_func): raise ViewDoesNotExist( - "Could not import '%s.%s'. View is not callable." % - (mod_name, func_name) + "Could not import '%s.%s'. View is not callable." + % (mod_name, func_name) ) return view_func @@ -56,7 +60,7 @@ def get_mod_func(callback): # Convert 'django.views.news.stories.story_detail' to # ['django.views.news.stories', 'story_detail'] try: - dot = callback.rindex('.') + dot = callback.rindex(".") except ValueError: - return callback, '' - return callback[:dot], callback[dot + 1:] + return callback, "" + return callback[:dot], callback[dot + 1 :] |
