diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admindocs/urls.py | 18 | ||||
| -rw-r--r-- | django/contrib/admindocs/views.py | 2 | ||||
| -rw-r--r-- | django/contrib/auth/password_validation.py | 2 | ||||
| -rw-r--r-- | django/contrib/humanize/templatetags/humanize.py | 2 | ||||
| -rw-r--r-- | django/core/checks/urls.py | 2 | ||||
| -rw-r--r-- | django/core/validators.py | 16 | ||||
| -rw-r--r-- | django/db/backends/base/operations.py | 2 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/introspection.py | 6 | ||||
| -rw-r--r-- | django/db/migrations/writer.py | 2 | ||||
| -rw-r--r-- | django/template/base.py | 2 | ||||
| -rw-r--r-- | django/template/defaultfilters.py | 2 | ||||
| -rw-r--r-- | django/template/defaulttags.py | 2 | ||||
| -rw-r--r-- | django/test/client.py | 2 | ||||
| -rw-r--r-- | django/test/html.py | 2 | ||||
| -rw-r--r-- | django/utils/html.py | 2 | ||||
| -rw-r--r-- | django/utils/regex_helper.py | 4 | ||||
| -rw-r--r-- | django/utils/text.py | 8 | ||||
| -rw-r--r-- | django/utils/translation/__init__.py | 2 | ||||
| -rw-r--r-- | django/views/debug.py | 2 |
19 files changed, 40 insertions, 40 deletions
diff --git a/django/contrib/admindocs/urls.py b/django/contrib/admindocs/urls.py index e0b2259ef9..bfc9648e83 100644 --- a/django/contrib/admindocs/urls.py +++ b/django/contrib/admindocs/urls.py @@ -2,31 +2,31 @@ from django.conf.urls import url from django.contrib.admindocs import views urlpatterns = [ - url('^$', + url(r'^$', views.BaseAdminDocsView.as_view(template_name='admin_doc/index.html'), name='django-admindocs-docroot'), - url('^bookmarklets/$', + url(r'^bookmarklets/$', views.BookmarkletsView.as_view(), name='django-admindocs-bookmarklets'), - url('^tags/$', + url(r'^tags/$', views.TemplateTagIndexView.as_view(), name='django-admindocs-tags'), - url('^filters/$', + url(r'^filters/$', views.TemplateFilterIndexView.as_view(), name='django-admindocs-filters'), - url('^views/$', + url(r'^views/$', views.ViewIndexView.as_view(), name='django-admindocs-views-index'), - url('^views/(?P<view>[^/]+)/$', + url(r'^views/(?P<view>[^/]+)/$', views.ViewDetailView.as_view(), name='django-admindocs-views-detail'), - url('^models/$', + url(r'^models/$', views.ModelIndexView.as_view(), name='django-admindocs-models-index'), - url('^models/(?P<app_label>[^\.]+)\.(?P<model_name>[^/]+)/$', + url(r'^models/(?P<app_label>[^\.]+)\.(?P<model_name>[^/]+)/$', views.ModelDetailView.as_view(), name='django-admindocs-models-detail'), - url('^templates/(?P<template>.*)/$', + url(r'^templates/(?P<template>.*)/$', views.TemplateDetailView.as_view(), name='django-admindocs-templates'), ] diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index 5fa3c46a8e..476d883a8d 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -430,7 +430,7 @@ non_named_group_matcher = re.compile(r'\(.*?\)') def simplify_regex(pattern): - """ + r""" Clean up urlpattern regexes into something more readable by humans. For example, turn "^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$" into "/<sport_slug>/athletes/<athlete_slug>/". diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py index 5fdae05a84..bee6bff942 100644 --- a/django/contrib/auth/password_validation.py +++ b/django/contrib/auth/password_validation.py @@ -143,7 +143,7 @@ class UserAttributeSimilarityValidator(object): value = getattr(user, attribute_name, None) if not value or not isinstance(value, string_types): continue - value_parts = re.split('\W+', value) + [value] + value_parts = re.split(r'\W+', value) + [value] for value_part in value_parts: if SequenceMatcher(a=password.lower(), b=value_part.lower()).quick_ratio() > self.max_similarity: try: diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index bb9bc7b1ca..6c43ace840 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -49,7 +49,7 @@ def intcomma(value, use_l10n=True): else: return number_format(value, force_grouping=True) orig = force_text(value) - new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', orig) + new = re.sub(r"^(-?\d+)(\d{3})", r'\g<1>,\g<2>', orig) if orig == new: return new else: diff --git a/django/core/checks/urls.py b/django/core/checks/urls.py index 8356fc2f00..e744cc0ca4 100644 --- a/django/core/checks/urls.py +++ b/django/core/checks/urls.py @@ -78,7 +78,7 @@ def check_include_trailing_dollar(pattern): Check that include is not used with a regex ending with a dollar. """ regex_pattern = pattern.regex.pattern - if regex_pattern.endswith('$') and not regex_pattern.endswith('\$'): + if regex_pattern.endswith('$') and not regex_pattern.endswith(r'\$'): warning = Warning( "Your URL pattern {} uses include with a regex ending with a '$'. " "Remove the dollar from the regex to avoid problems including " diff --git a/django/core/validators.py b/django/core/validators.py index 805dd8860f..5a7fd1a49b 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -88,12 +88,12 @@ class URLValidator(RegexValidator): # Max length for domain name labels is 63 characters per RFC 1034 sec. 3.1 domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]{1,63}(?<!-))*' tld_re = ( - '\.' # dot - '(?!-)' # can't start with a dash - '(?:[a-z' + ul + '-]{2,63}' # domain label - '|xn--[a-z0-9]{1,59})' # or punycode label - '(?<!-)' # can't end with a dash - '\.?' # may have a trailing dot + r'\.' # dot + r'(?!-)' # can't start with a dash + r'(?:[a-z' + ul + '-]{2,63}' # domain label + r'|xn--[a-z0-9]{1,59})' # or punycode label + r'(?<!-)' # can't end with a dash + r'\.?' # may have a trailing dot ) host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)' @@ -156,7 +156,7 @@ class URLValidator(RegexValidator): raise ValidationError(self.message, code=self.code) integer_validator = RegexValidator( - _lazy_re_compile('^-?\d+\Z'), + _lazy_re_compile(r'^-?\d+\Z'), message=_('Enter a valid integer.'), code='invalid', ) @@ -295,7 +295,7 @@ def ip_address_validators(protocol, unpack_ipv4): def int_list_validator(sep=',', message=None, code='invalid', allow_negative=False): - regexp = _lazy_re_compile('^%(neg)s\d+(?:%(sep)s%(neg)s\d+)*\Z' % { + regexp = _lazy_re_compile(r'^%(neg)s\d+(?:%(sep)s%(neg)s\d+)*\Z' % { 'neg': '(-)?' if allow_negative else '', 'sep': re.escape(sep), }) diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py index 1ed11b178e..a072687ebb 100644 --- a/django/db/backends/base/operations.py +++ b/django/db/backends/base/operations.py @@ -428,7 +428,7 @@ class BaseDatabaseOperations(object): def prep_for_like_query(self, x): """Prepares a value for use in a LIKE query.""" - return force_text(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_") + return force_text(x).replace("\\", "\\\\").replace("%", r"\%").replace("_", r"\_") # Same as prep_for_like_query(), but called for "iexact" matches, which # need not necessarily be implemented using "LIKE" in the backend. diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py index 2ed629f94a..ce5e7032fb 100644 --- a/django/db/backends/sqlite3/introspection.py +++ b/django/db/backends/sqlite3/introspection.py @@ -125,14 +125,14 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): if field_desc.startswith("UNIQUE"): continue - m = re.search('references (\S*) ?\(["|]?(.*)["|]?\)', field_desc, re.I) + m = re.search(r'references (\S*) ?\(["|]?(.*)["|]?\)', field_desc, re.I) if not m: continue table, column = [s.strip('"') for s in m.groups()] if field_desc.startswith("FOREIGN KEY"): # Find name of the target FK field - m = re.match('FOREIGN KEY\(([^\)]*)\).*', field_desc, re.I) + m = re.match(r'FOREIGN KEY\(([^\)]*)\).*', field_desc, re.I) field_name = m.groups()[0].strip('"') else: field_name = field_desc.split()[0].strip('"') @@ -175,7 +175,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): if field_desc.startswith("UNIQUE"): continue - m = re.search('"(.*)".*references (.*) \(["|](.*)["|]\)', field_desc, re.I) + m = re.search(r'"(.*)".*references (.*) \(["|](.*)["|]\)', field_desc, re.I) if not m: continue diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py index 7c39cdc931..e75f5bfdd1 100644 --- a/django/db/migrations/writer.py +++ b/django/db/migrations/writer.py @@ -181,7 +181,7 @@ class MigrationWriter(object): # for comments migration_imports = set() for line in list(imports): - if re.match("^import (.*)\.\d+[^\s]*$", line): + if re.match(r"^import (.*)\.\d+[^\s]*$", line): migration_imports.add(line.split("import")[1].strip()) imports.remove(line) self.needs_manual_porting = True diff --git a/django/template/base.py b/django/template/base.py index 778d82be55..13037c31aa 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -639,7 +639,7 @@ filter_raw_string = r""" )""" % { 'constant': constant_string, 'num': r'[-+\.]?\d[\d\.e]*', - 'var_chars': "\w\.", + 'var_chars': r'\w\.', 'filter_sep': re.escape(FILTER_SEPARATOR), 'arg_sep': re.escape(FILTER_ARGUMENT_SEPARATOR), } diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index e3dc48e474..b258cf269b 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -259,7 +259,7 @@ def stringformat(value, arg): def title(value): """Converts a string into titlecase.""" t = re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title()) - return re.sub("\d([A-Z])", lambda m: m.group(0).lower(), t) + return re.sub(r"\d([A-Z])", lambda m: m.group(0).lower(), t) @register.filter(is_safe=True) diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index ece6f7501d..71fcbbaab3 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -1329,7 +1329,7 @@ def templatetag(parser, token): @register.tag def url(parser, token): - """ + r""" Return an absolute URL matching the given view with its parameters. This is a way to define links that aren't tied to a particular URL diff --git a/django/test/client.py b/django/test/client.py index af55f9efb4..aea051ed2b 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -33,7 +33,7 @@ __all__ = ('Client', 'RedirectCycleError', 'RequestFactory', 'encode_file', 'enc BOUNDARY = 'BoUnDaRyStRiNg' MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY -CONTENT_TYPE_RE = re.compile('.*; charset=([\w\d-]+);?') +CONTENT_TYPE_RE = re.compile(r'.*; charset=([\w\d-]+);?') class RedirectCycleError(Exception): diff --git a/django/test/html.py b/django/test/html.py index 195c61ede0..dfff8d6369 100644 --- a/django/test/html.py +++ b/django/test/html.py @@ -10,7 +10,7 @@ from django.utils import six from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html_parser import HTMLParseError, HTMLParser -WHITESPACE = re.compile('\s+') +WHITESPACE = re.compile(r'\s+') def normalize_whitespace(string): diff --git a/django/utils/html.py b/django/utils/html.py index a5cb56ec9e..84379caa9c 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -36,7 +36,7 @@ simple_email_re = re.compile(r'^\S+@\S+\.\S+$') link_target_attribute_re = re.compile(r'(<a [^>]*?)target=[^\s>]+') html_gunk_re = re.compile( r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|' - '<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) + r'<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) hard_coded_bullets_re = re.compile( r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join(re.escape(x) for x in DOTS), re.DOTALL ) diff --git a/django/utils/regex_helper.py b/django/utils/regex_helper.py index 4a697b2920..622d822759 100644 --- a/django/utils/regex_helper.py +++ b/django/utils/regex_helper.py @@ -48,7 +48,7 @@ class NonCapture(list): def normalize(pattern): - """ + r""" Given a reg-exp pattern, normalizes it to an iterable of forms that suffice for reverse matching. This does the following: @@ -203,7 +203,7 @@ def normalize(pattern): def next_char(input_iter): - """ + r""" An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w -> "x"). If the escaped character is one that is diff --git a/django/utils/text.py b/django/utils/text.py index 3b8fc581bf..a77f27eed7 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -423,11 +423,11 @@ def slugify(value, allow_unicode=False): value = force_text(value) if allow_unicode: value = unicodedata.normalize('NFKC', value) - value = re.sub('[^\w\s-]', '', value, flags=re.U).strip().lower() - return mark_safe(re.sub('[-\s]+', '-', value, flags=re.U)) + value = re.sub(r'[^\w\s-]', '', value, flags=re.U).strip().lower() + return mark_safe(re.sub(r'[-\s]+', '-', value, flags=re.U)) value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') - value = re.sub('[^\w\s-]', '', value).strip().lower() - return mark_safe(re.sub('[-\s]+', '-', value)) + value = re.sub(r'[^\w\s-]', '', value).strip().lower() + return mark_safe(re.sub(r'[-\s]+', '-', value)) def camel_case_to_spaces(value): diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py index 9154ceeb7b..a5975b005c 100644 --- a/django/utils/translation/__init__.py +++ b/django/utils/translation/__init__.py @@ -255,7 +255,7 @@ def get_language_info(lang_code): info['name_translated'] = ugettext_lazy(info['name']) return info -trim_whitespace_re = re.compile('\s*\n\s*') +trim_whitespace_re = re.compile(r'\s*\n\s*') def trim_whitespace(s): diff --git a/django/views/debug.py b/django/views/debug.py index a92f487bb1..f7c685893c 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -537,7 +537,7 @@ TECHNICAL_500_TEMPLATE = (""" <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="robots" content="NONE,NOARCHIVE"> <title>{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}""" -"""{% if request %} at {{ request.path_info|escape }}{% endif %}</title> +r"""{% if request %} at {{ request.path_info|escape }}{% endif %}</title> <style type="text/css"> html * { padding:0; margin:0; } body * { padding:10px 20px; } |
