summaryrefslogtreecommitdiff
path: root/django/urls/conf.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /django/urls/conf.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'django/urls/conf.py')
-rw-r--r--django/urls/conf.py42
1 files changed, 24 insertions, 18 deletions
diff --git a/django/urls/conf.py b/django/urls/conf.py
index 40990d10f5..40708028a3 100644
--- a/django/urls/conf.py
+++ b/django/urls/conf.py
@@ -5,7 +5,11 @@ from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from .resolvers import (
- LocalePrefixPattern, RegexPattern, RoutePattern, URLPattern, URLResolver,
+ LocalePrefixPattern,
+ RegexPattern,
+ RoutePattern,
+ URLPattern,
+ URLResolver,
)
@@ -18,13 +22,13 @@ def include(arg, namespace=None):
except ValueError:
if namespace:
raise ImproperlyConfigured(
- 'Cannot override the namespace for a dynamic module that '
- 'provides a namespace.'
+ "Cannot override the namespace for a dynamic module that "
+ "provides a namespace."
)
raise ImproperlyConfigured(
- 'Passing a %d-tuple to include() is not supported. Pass a '
- '2-tuple containing the list of patterns and app_name, and '
- 'provide the namespace argument to include() instead.' % len(arg)
+ "Passing a %d-tuple to include() is not supported. Pass a "
+ "2-tuple containing the list of patterns and app_name, and "
+ "provide the namespace argument to include() instead." % len(arg)
)
else:
# No namespace hint - use manually provided namespace.
@@ -32,24 +36,24 @@ def include(arg, namespace=None):
if isinstance(urlconf_module, str):
urlconf_module = import_module(urlconf_module)
- patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module)
- app_name = getattr(urlconf_module, 'app_name', app_name)
+ patterns = getattr(urlconf_module, "urlpatterns", urlconf_module)
+ app_name = getattr(urlconf_module, "app_name", app_name)
if namespace and not app_name:
raise ImproperlyConfigured(
- 'Specifying a namespace in include() without providing an app_name '
- 'is not supported. Set the app_name attribute in the included '
- 'module, or pass a 2-tuple containing the list of patterns and '
- 'app_name instead.',
+ "Specifying a namespace in include() without providing an app_name "
+ "is not supported. Set the app_name attribute in the included "
+ "module, or pass a 2-tuple containing the list of patterns and "
+ "app_name instead.",
)
namespace = namespace or app_name
# Make sure the patterns can be iterated through (without this, some
# testcases will break).
if isinstance(patterns, (list, tuple)):
for url_pattern in patterns:
- pattern = getattr(url_pattern, 'pattern', None)
+ pattern = getattr(url_pattern, "pattern", None)
if isinstance(pattern, LocalePrefixPattern):
raise ImproperlyConfigured(
- 'Using i18n_patterns in an included URLconf is not allowed.'
+ "Using i18n_patterns in an included URLconf is not allowed."
)
return (urlconf_module, app_name, namespace)
@@ -59,7 +63,7 @@ def _path(route, view, kwargs=None, name=None, Pattern=None):
if kwargs is not None and not isinstance(kwargs, dict):
raise TypeError(
- f'kwargs argument must be a dict, but got {kwargs.__class__.__name__}.'
+ f"kwargs argument must be a dict, but got {kwargs.__class__.__name__}."
)
if isinstance(view, (list, tuple)):
# For include(...) processing.
@@ -78,11 +82,13 @@ def _path(route, view, kwargs=None, name=None, Pattern=None):
elif isinstance(view, View):
view_cls_name = view.__class__.__name__
raise TypeError(
- f'view must be a callable, pass {view_cls_name}.as_view(), not '
- f'{view_cls_name}().'
+ f"view must be a callable, pass {view_cls_name}.as_view(), not "
+ f"{view_cls_name}()."
)
else:
- raise TypeError('view must be a callable or a list/tuple in the case of include().')
+ raise TypeError(
+ "view must be a callable or a list/tuple in the case of include()."
+ )
path = partial(_path, Pattern=RoutePattern)