From a5b062576bda29abe93504dbcb126e644d07f9dd Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 22 Sep 2013 14:01:57 +0200 Subject: [PATCH] Removed a few trailing backslashes. We have always been at war with trailing backslashes. --- django/conf/__init__.py | 4 ++-- django/contrib/auth/management/__init__.py | 5 +++-- django/contrib/auth/tests/test_remote_user.py | 6 ++---- django/db/models/sql/expressions.py | 3 +-- django/shortcuts/__init__.py | 6 ++++-- django/template/response.py | 3 +-- django/templatetags/i18n.py | 2 +- django/test/client.py | 4 ++-- django/test/testcases.py | 5 ++--- django/utils/encoding.py | 4 ++-- django/utils/feedgenerator.py | 2 +- django/utils/html_parser.py | 8 ++++---- django/utils/http.py | 4 ++-- tests/urlpatterns_reverse/tests.py | 2 +- 14 files changed, 28 insertions(+), 30 deletions(-) diff --git a/django/conf/__init__.py b/django/conf/__init__.py index 199c34fb55..7a915f1486 100644 --- a/django/conf/__init__.py +++ b/django/conf/__init__.py @@ -139,8 +139,8 @@ class Settings(BaseSettings): if setting == setting.upper(): setting_value = getattr(mod, setting) - if setting in tuple_settings and \ - isinstance(setting_value, six.string_types): + if (setting in tuple_settings and + isinstance(setting_value, six.string_types)): raise ImproperlyConfigured("The %s setting must be a tuple. " "Please fix your settings." % setting) diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py index c53d581858..cb77694d1c 100644 --- a/django/contrib/auth/management/__init__.py +++ b/django/contrib/auth/management/__init__.py @@ -167,8 +167,9 @@ def get_default_username(check_db=True): default_username = get_system_username() try: - default_username = unicodedata.normalize('NFKD', default_username)\ - .encode('ascii', 'ignore').decode('ascii').replace(' ', '').lower() + default_username = (unicodedata.normalize('NFKD', default_username) + .encode('ascii', 'ignore').decode('ascii') + .replace(' ', '').lower()) except UnicodeDecodeError: return '' diff --git a/django/contrib/auth/tests/test_remote_user.py b/django/contrib/auth/tests/test_remote_user.py index 5c5024eae9..656a72a61d 100644 --- a/django/contrib/auth/tests/test_remote_user.py +++ b/django/contrib/auth/tests/test_remote_user.py @@ -136,8 +136,7 @@ class RemoteUserNoCreateTest(RemoteUserTest): class that doesn't create unknown users. """ - backend =\ - 'django.contrib.auth.tests.test_remote_user.RemoteUserNoCreateBackend' + backend = 'django.contrib.auth.tests.test_remote_user.RemoteUserNoCreateBackend' def test_unknown_user(self): num_users = User.objects.count() @@ -173,8 +172,7 @@ class RemoteUserCustomTest(RemoteUserTest): and configure_user methods. """ - backend =\ - 'django.contrib.auth.tests.test_remote_user.CustomRemoteUserBackend' + backend = 'django.contrib.auth.tests.test_remote_user.CustomRemoteUserBackend' # REMOTE_USER strings with email addresses for the custom backend to # clean. known_user = 'knownuser@example.com' diff --git a/django/db/models/sql/expressions.py b/django/db/models/sql/expressions.py index f9a8929974..1846d2cd53 100644 --- a/django/db/models/sql/expressions.py +++ b/django/db/models/sql/expressions.py @@ -111,8 +111,7 @@ class SQLEvaluator(object): timedelta = node.children.pop() sql, params = self.evaluate_node(node, qn, connection) - if timedelta.days == 0 and timedelta.seconds == 0 and \ - timedelta.microseconds == 0: + if (timedelta.days == timedelta.seconds == timedelta.microseconds == 0): return sql, params return connection.ops.date_interval_sql(sql, node.connector, timedelta), params diff --git a/django/shortcuts/__init__.py b/django/shortcuts/__init__.py index b096efdb44..3efdb784af 100644 --- a/django/shortcuts/__init__.py +++ b/django/shortcuts/__init__.py @@ -83,8 +83,10 @@ def _get_queryset(klass): elif isinstance(klass, ModelBase): manager = klass._default_manager else: - klass__name = klass.__name__ if isinstance(klass, type) \ - else klass.__class__.__name__ + if isinstance(klass, type) + klass__name = klass.__name__ + else: + klass__name = klass.__class__.__name__ raise ValueError("Object is of type '%s', but must be a Django Model, " "Manager, or QuerySet" % klass__name) return manager.all() diff --git a/django/template/response.py b/django/template/response.py index aa4f12af44..f673c5f46a 100644 --- a/django/template/response.py +++ b/django/template/response.py @@ -133,8 +133,7 @@ class SimpleTemplateResponse(HttpResponse): class TemplateResponse(SimpleTemplateResponse): - rendering_attrs = SimpleTemplateResponse.rendering_attrs + \ - ['_request', '_current_app'] + rendering_attrs = SimpleTemplateResponse.rendering_attrs + ['_request', '_current_app'] def __init__(self, request, template, context=None, content_type=None, status=None, current_app=None): diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py index bce10b9de6..22fb4eb1a7 100644 --- a/django/templatetags/i18n.py +++ b/django/templatetags/i18n.py @@ -359,7 +359,7 @@ def do_translate(parser, token): asvar = self.tag() else: raise TemplateSyntaxError( - "Only options for 'trans' are 'noop', " \ + "Only options for 'trans' are 'noop', " "'context \"xxx\"', and 'as VAR'.") return value, noop, asvar, message_context value, noop, asvar, message_context = TranslateParser(token.contents).top() diff --git a/django/test/client.py b/django/test/client.py index 11921ccf03..be2c3c8136 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -524,8 +524,8 @@ class Client(RequestFactory): not available. """ user = authenticate(**credentials) - if user and user.is_active \ - and 'django.contrib.sessions' in settings.INSTALLED_APPS: + if (user and user.is_active and + 'django.contrib.sessions' in settings.INSTALLED_APPS): engine = import_module(settings.SESSION_ENGINE) # Create a fake request to store login details. diff --git a/django/test/testcases.py b/django/test/testcases.py index caff63039a..0a61a21ccf 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -734,9 +734,8 @@ class TransactionTestCase(SimpleTestCase): def _reset_sequences(self, db_name): conn = connections[db_name] if conn.features.supports_sequence_reset: - sql_list = \ - conn.ops.sequence_reset_by_name_sql(no_style(), - conn.introspection.sequence_list()) + sql_list = conn.ops.sequence_reset_by_name_sql( + no_style(), conn.introspection.sequence_list()) if sql_list: with transaction.commit_on_success_unless_managed(using=db_name): cursor = conn.cursor() diff --git a/django/utils/encoding.py b/django/utils/encoding.py index a7239f4b0f..bb07deb894 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -152,13 +152,13 @@ else: smart_unicode = smart_text force_unicode = force_text -smart_str.__doc__ = """\ +smart_str.__doc__ = """ Apply smart_text in Python 3 and smart_bytes in Python 2. This is suitable for writing to sys.stdout (for instance). """ -force_str.__doc__ = """\ +force_str.__doc__ = """ Apply force_text in Python 3 and force_bytes in Python 2. """ diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index f7fec5e7f9..441935586d 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -272,7 +272,7 @@ class Rss201rev2Feed(RssFeed): # Author information. if item["author_name"] and item["author_email"]: - handler.addQuickElement("author", "%s (%s)" % \ + handler.addQuickElement("author", "%s (%s)" % (item['author_email'], item['author_name'])) elif item["author_email"]: handler.addQuickElement("author", item["author_email"]) diff --git a/django/utils/html_parser.py b/django/utils/html_parser.py index 6ccb665249..2a408e9f55 100644 --- a/django/utils/html_parser.py +++ b/django/utils/html_parser.py @@ -59,8 +59,8 @@ else: attrname, rest, attrvalue = m.group(1, 2, 3) if not rest: attrvalue = None - elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ - attrvalue[:1] == '"' == attrvalue[-1:]: + elif (attrvalue[:1] == '\'' == attrvalue[-1:] or + attrvalue[:1] == '"' == attrvalue[-1:]): attrvalue = attrvalue[1:-1] if attrvalue: attrvalue = self.unescape(attrvalue) @@ -72,8 +72,8 @@ else: lineno, offset = self.getpos() if "\n" in self.__starttag_text: lineno = lineno + self.__starttag_text.count("\n") - offset = len(self.__starttag_text) \ - - self.__starttag_text.rfind("\n") + offset = (len(self.__starttag_text) + - self.__starttag_text.rfind("\n")) else: offset = offset + len(self.__starttag_text) self.error("junk characters in start tag: %r" diff --git a/django/utils/http.py b/django/utils/http.py index fb6c4b31ca..9ebbb88723 100644 --- a/django/utils/http.py +++ b/django/utils/http.py @@ -256,5 +256,5 @@ def is_safe_url(url, host=None): if not url: return False url_info = urlparse(url) - return (not url_info.netloc or url_info.netloc == host) and \ - (not url_info.scheme or url_info.scheme in ['http', 'https']) + return ((not url_info.netloc or url_info.netloc == host) and + (not url_info.scheme or url_info.scheme in ['http', 'https'])) diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py index fd0f2cd6c2..4d77dc946d 100644 --- a/tests/urlpatterns_reverse/tests.py +++ b/tests/urlpatterns_reverse/tests.py @@ -158,7 +158,7 @@ class NoURLPatternsTests(TestCase): resolver = RegexURLResolver(r'^$', self.urls) self.assertRaisesMessage(ImproperlyConfigured, - "The included urlconf urlpatterns_reverse.no_urls "\ + "The included urlconf urlpatterns_reverse.no_urls " "doesn't have any patterns in it", getattr, resolver, 'url_patterns') class URLPatternReverse(TestCase):