From ebf34c3cdcd2c75349c60a064427ac255958bf9b Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Wed, 25 Jan 2017 15:14:05 +0100 Subject: [PATCH] Removed unused variables that are overwritten. --- django/contrib/admindocs/views.py | 1 - django/core/validators.py | 1 - django/db/backends/mysql/creation.py | 2 +- django/db/backends/postgresql/creation.py | 2 +- django/db/models/sql/compiler.py | 1 - django/http/multipartparser.py | 4 ---- django/template/base.py | 2 +- django/utils/dateformat.py | 1 - django/utils/ipv6.py | 1 - tests/bulk_create/tests.py | 2 -- tests/migrations/test_base.py | 2 +- tests/urlpatterns_reverse/tests.py | 1 - 12 files changed, 4 insertions(+), 16 deletions(-) diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index 4a8e1eb599..f049c5f367 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -296,7 +296,6 @@ class ModelDetailView(BaseAdminDocsView): }) else: arguments = get_func_full_args(func) - print_arguments = arguments # Join arguments with ', ' and in case of default value, # join it with '='. Use repr() so that strings will be # correctly displayed. diff --git a/django/core/validators.py b/django/core/validators.py index b3b76f25f9..1dc0f2fbcd 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -140,7 +140,6 @@ class URLValidator(RegexValidator): validate_ipv6_address(potential_ip) except ValidationError: raise ValidationError(self.message, code=self.code) - url = value # The maximum length of a full host name is 253 characters per RFC 1034 # section 3.1. It's defined to be 255 bytes or less, but this includes diff --git a/django/db/backends/mysql/creation.py b/django/db/backends/mysql/creation.py index ae4370935a..c53b9f8335 100644 --- a/django/db/backends/mysql/creation.py +++ b/django/db/backends/mysql/creation.py @@ -25,7 +25,7 @@ class DatabaseCreation(BaseDatabaseCreation): with self._nodb_connection.cursor() as cursor: try: cursor.execute("CREATE DATABASE %s" % qn(target_database_name)) - except Exception as e: + except Exception: if keepdb: return try: diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py index 2f26b14e52..c47bb534f2 100644 --- a/django/db/backends/postgresql/creation.py +++ b/django/db/backends/postgresql/creation.py @@ -41,7 +41,7 @@ class DatabaseCreation(BaseDatabaseCreation): with self._nodb_connection.cursor() as cursor: try: cursor.execute(creation_sql) - except Exception as e: + except Exception: if keepdb: return try: diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 5e5984dfb3..560ea2ef6d 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -823,7 +823,6 @@ class SQLCompiler: """ Returns an iterator over the results from executing this query. """ - converters = None if results is None: results = self.execute_sql(MULTI) fields = [s[0] for s in self.select[0:self.col_count]] diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index 6a0ff2c86c..adb4e08dbe 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -571,15 +571,11 @@ def exhaust(stream_or_iterable): Raise a MultiPartParserError if the argument is not a stream or an iterable. """ - iterator = None try: iterator = iter(stream_or_iterable) except TypeError: iterator = ChunkIter(stream_or_iterable, 16384) - if iterator is None: - raise MultiPartParserError('multipartparser.exhaust() was passed a non-iterable or stream parameter') - for __ in iterator: pass diff --git a/django/template/base.py b/django/template/base.py index b4d129c0a4..0c796ceaf2 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -853,7 +853,7 @@ class Variable: if isinstance(current, BaseContext) and getattr(type(current), bit): raise AttributeError current = getattr(current, bit) - except (TypeError, AttributeError) as e: + except (TypeError, AttributeError): # Reraise if the exception was raised by a @property if not isinstance(current, BaseContext) and bit in dir(current): raise diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py index f55b97c2ed..67968e5d73 100644 --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -324,7 +324,6 @@ class DateFormat(TimeFormat): def W(self): "ISO-8601 week number of year, weeks starting on Monday" # Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt - week_number = None jan1_weekday = self.data.replace(month=1, day=1).weekday() + 1 weekday = self.data.weekday() + 1 day_of_year = self.z() diff --git a/django/utils/ipv6.py b/django/utils/ipv6.py index a1e63be727..93a1bfd1b2 100644 --- a/django/utils/ipv6.py +++ b/django/utils/ipv6.py @@ -227,7 +227,6 @@ def _explode_shorthand_ip_string(ip_str): # We've already got a longhand ip_str. return ip_str - new_ip = [] hextet = ip_str.split('::') # If there is a ::, we need to expand it with zeroes diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py index 65d0f9ba8c..97a8f82117 100644 --- a/tests/bulk_create/tests.py +++ b/tests/bulk_create/tests.py @@ -206,7 +206,6 @@ class BulkCreateTests(TestCase): @skipUnlessDBFeature('can_return_ids_from_bulk_insert') def test_set_pk_and_insert_single_item(self): - countries = [] with self.assertNumQueries(1): countries = Country.objects.bulk_create([self.data[0]]) self.assertEqual(len(countries), 1) @@ -214,7 +213,6 @@ class BulkCreateTests(TestCase): @skipUnlessDBFeature('can_return_ids_from_bulk_insert') def test_set_pk_and_query_efficiency(self): - countries = [] with self.assertNumQueries(1): countries = Country.objects.bulk_create(self.data) self.assertEqual(len(countries), 4) diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py index 7f7f96c013..007c7c0ba9 100644 --- a/tests/migrations/test_base.py +++ b/tests/migrations/test_base.py @@ -77,7 +77,7 @@ class MigrationTestBase(TransactionTestCase): ), ) - def assertFKNotExists(self, table, columns, to, value=True): + def assertFKNotExists(self, table, columns, to): return self.assertFKExists(table, columns, to, False) @contextmanager diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py index a1241b2fab..b2d7e1ad38 100644 --- a/tests/urlpatterns_reverse/tests.py +++ b/tests/urlpatterns_reverse/tests.py @@ -426,7 +426,6 @@ class ResolverTests(SimpleTestCase): e = cm.exception # make sure we at least matched the root ('/') url resolver: self.assertIn('tried', e.args[0]) - tried = e.args[0]['tried'] self.assertEqual( len(e.args[0]['tried']), len(url_types_names),