diff --git a/setup.cfg b/setup.cfg
index c7f2e5b4f3..a121fc0d46 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
[flake8]
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py
-ignore=E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,F401,F403,F841,W601
+ignore=E124,E125,E126,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,F401,F403,W601
[metadata]
license-file = LICENSE
diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py
index 5353a16e42..3692683cae 100644
--- a/tests/deprecation/tests.py
+++ b/tests/deprecation/tests.py
@@ -168,7 +168,7 @@ class DeprecatingRequestMergeDictTest(SimpleTestCase):
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter('always')
request = RequestFactory().get('/')
- _ = request.REQUEST
+ request.REQUEST # evaluate
msgs = [str(warning.message) for warning in recorded]
self.assertEqual(msgs, [
diff --git a/tests/expressions_regress/tests.py b/tests/expressions_regress/tests.py
index a637d88e68..6d96e0cd7e 100644
--- a/tests/expressions_regress/tests.py
+++ b/tests/expressions_regress/tests.py
@@ -351,7 +351,7 @@ class FTimeDeltaTests(TestCase):
def test_delta_invalid_op_mult(self):
raised = False
try:
- r = repr(Experiment.objects.filter(end__lt=F('start')*self.deltas[0]))
+ repr(Experiment.objects.filter(end__lt=F('start')*self.deltas[0]))
except TypeError:
raised = True
self.assertTrue(raised, "TypeError not raised on attempt to multiply datetime by timedelta.")
@@ -359,7 +359,7 @@ class FTimeDeltaTests(TestCase):
def test_delta_invalid_op_div(self):
raised = False
try:
- r = repr(Experiment.objects.filter(end__lt=F('start')/self.deltas[0]))
+ repr(Experiment.objects.filter(end__lt=F('start')/self.deltas[0]))
except TypeError:
raised = True
self.assertTrue(raised, "TypeError not raised on attempt to divide datetime by timedelta.")
@@ -367,7 +367,7 @@ class FTimeDeltaTests(TestCase):
def test_delta_invalid_op_mod(self):
raised = False
try:
- r = repr(Experiment.objects.filter(end__lt=F('start') % self.deltas[0]))
+ repr(Experiment.objects.filter(end__lt=F('start') % self.deltas[0]))
except TypeError:
raised = True
self.assertTrue(raised, "TypeError not raised on attempt to modulo divide datetime by timedelta.")
@@ -375,7 +375,7 @@ class FTimeDeltaTests(TestCase):
def test_delta_invalid_op_and(self):
raised = False
try:
- r = repr(Experiment.objects.filter(end__lt=F('start').bitand(self.deltas[0])))
+ repr(Experiment.objects.filter(end__lt=F('start').bitand(self.deltas[0])))
except TypeError:
raised = True
self.assertTrue(raised, "TypeError not raised on attempt to binary and a datetime with a timedelta.")
@@ -383,7 +383,7 @@ class FTimeDeltaTests(TestCase):
def test_delta_invalid_op_or(self):
raised = False
try:
- r = repr(Experiment.objects.filter(end__lt=F('start').bitor(self.deltas[0])))
+ repr(Experiment.objects.filter(end__lt=F('start').bitor(self.deltas[0])))
except TypeError:
raised = True
self.assertTrue(raised, "TypeError not raised on attempt to binary or a datetime with a timedelta.")
diff --git a/tests/extra_regress/tests.py b/tests/extra_regress/tests.py
index a34c1f5a5f..0e6f270ead 100644
--- a/tests/extra_regress/tests.py
+++ b/tests/extra_regress/tests.py
@@ -160,7 +160,7 @@ class ExtraRegressTests(TestCase):
columns, we can (and should) ignore those columns. They don't change
the result and cause incorrect SQL to be produced otherwise.
"""
- rm = RevisionableModel.objects.create(
+ RevisionableModel.objects.create(
title='First Revision',
when=datetime.datetime(2008, 9, 28, 10, 30, 0)
)
diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py
index ba09671a1e..49bc57f8f1 100644
--- a/tests/field_deconstruction/tests.py
+++ b/tests/field_deconstruction/tests.py
@@ -174,7 +174,7 @@ class FieldDeconstructionTests(TestCase):
self.assertEqual(kwargs, {})
def test_ip_address_field(self):
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
field = models.IPAddressField()
name, path, args, kwargs = field.deconstruct()
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index bd9510e698..10a316c3b0 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -241,8 +241,8 @@ class FileStorageTests(unittest.TestCase):
self.assertFalse(self.storage.exists('storage_test_2'))
self.assertFalse(self.storage.exists('storage_dir_1'))
- f = self.storage.save('storage_test_1', ContentFile('custom content'))
- f = self.storage.save('storage_test_2', ContentFile('custom content'))
+ self.storage.save('storage_test_1', ContentFile('custom content'))
+ self.storage.save('storage_test_2', ContentFile('custom content'))
os.mkdir(os.path.join(self.temp_dir, 'storage_dir_1'))
dirs, files = self.storage.listdir('')
@@ -428,7 +428,7 @@ class FileSaveRaceConditionTest(unittest.TestCase):
def test_race_condition(self):
self.thread.start()
- name = self.save_file('conflict')
+ self.save_file('conflict')
self.thread.join()
self.assertTrue(self.storage.exists('conflict'))
self.assertTrue(self.storage.exists('conflict_1'))
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py
index 703d512ef6..7724578e2a 100644
--- a/tests/file_uploads/tests.py
+++ b/tests/file_uploads/tests.py
@@ -335,7 +335,7 @@ class FileUploadTests(TestCase):
"""A handler that'll access POST during an exception."""
def handle_uncaught_exception(self, request, resolver, exc_info):
ret = super(POSTAccessingHandler, self).handle_uncaught_exception(request, resolver, exc_info)
- p = request.POST
+ request.POST # evaluate
return ret
# Maybe this is a little more complicated that it needs to be; but if
@@ -356,7 +356,7 @@ class FileUploadTests(TestCase):
'file_field': fp,
}
try:
- response = self.client.post('/file_uploads/upload_errors/', post_data)
+ self.client.post('/file_uploads/upload_errors/', post_data)
except reference_error.__class__ as err:
self.assertFalse(
str(err) == str(reference_error),
@@ -444,7 +444,7 @@ class MultiParserTests(unittest.TestCase):
def test_empty_upload_handlers(self):
# We're not actually parsing here; just checking if the parser properly
# instantiates with empty upload handlers.
- parser = MultiPartParser({
+ MultiPartParser({
'CONTENT_TYPE': 'multipart/form-data; boundary=_foo',
'CONTENT_LENGTH': '1'
}, StringIO('x'), [], 'utf-8')
diff --git a/tests/files/tests.py b/tests/files/tests.py
index 105d8c3ff9..900e79c40f 100644
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -170,7 +170,7 @@ class FileTests(unittest.TestCase):
# See #14681, stdlib gzip module crashes if mode is set to None
file = SimpleUploadedFile("mode_test.txt", b"content")
self.assertFalse(hasattr(file, 'mode'))
- g = gzip.GzipFile(fileobj=file)
+ gzip.GzipFile(fileobj=file)
class FileMoveSafeTests(unittest.TestCase):
diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py
index 818556ce7f..5863b457f4 100644
--- a/tests/forms_tests/tests/test_error_messages.py
+++ b/tests/forms_tests/tests/test_error_messages.py
@@ -194,7 +194,7 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
'required': 'REQUIRED',
'invalid': 'INVALID IP ADDRESS',
}
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
f = IPAddressField(error_messages=e)
self.assertFormErrors(['REQUIRED'], f.clean, '')
@@ -243,9 +243,9 @@ class ModelChoiceFieldErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
def test_modelchoicefield(self):
# Create choices for the model choice field tests below.
from forms_tests.models import ChoiceModel
- c1 = ChoiceModel.objects.create(pk=1, name='a')
- c2 = ChoiceModel.objects.create(pk=2, name='b')
- c3 = ChoiceModel.objects.create(pk=3, name='c')
+ ChoiceModel.objects.create(pk=1, name='a')
+ ChoiceModel.objects.create(pk=2, name='b')
+ ChoiceModel.objects.create(pk=3, name='c')
# ModelChoiceField
e = {
diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py
index 8754c2f2e2..f32c764a1e 100644
--- a/tests/forms_tests/tests/test_extra.py
+++ b/tests/forms_tests/tests/test_extra.py
@@ -535,7 +535,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self.assertEqual(f.cleaned_data['field1'], 'some text,JP,2007-04-25 06:24:00')
def test_ipaddress(self):
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
f = IPAddressField()
self.assertFormErrors(['This field is required.'], f.clean, '')
@@ -546,7 +546,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self.assertFormErrors(['Enter a valid IPv4 address.'], f.clean, '1.2.3.4.5')
self.assertFormErrors(['Enter a valid IPv4 address.'], f.clean, '256.125.1.5')
- with warnings.catch_warnings(record=True) as w:
+ with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
f = IPAddressField(required=False)
self.assertEqual(f.clean(''), '')
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
index 4b4a4bc001..3ecf693d70 100644
--- a/tests/forms_tests/tests/test_formsets.py
+++ b/tests/forms_tests/tests/test_formsets.py
@@ -336,20 +336,6 @@ class FormsFormsetTestCase(TestCase):
def test_more_initial_data(self):
# The extra argument also works when the formset is pre-filled with initial
# data.
-
- data = {
- 'choices-TOTAL_FORMS': '3', # the number of forms rendered
- 'choices-INITIAL_FORMS': '0', # the number of forms with initial data
- 'choices-MIN_NUM_FORMS': '0', # min number of forms
- 'choices-MAX_NUM_FORMS': '0', # max number of forms
- 'choices-0-choice': 'Calexico',
- 'choices-0-votes': '100',
- 'choices-1-choice': '',
- 'choices-1-votes': '', # missing value
- 'choices-2-choice': '',
- 'choices-2-votes': '',
- }
-
initial = [{'choice': 'Calexico', 'votes': 100}]
ChoiceFormSet = formset_factory(Choice, extra=3)
formset = ChoiceFormSet(initial=initial, auto_id=False, prefix='choices')
diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py
index 159d03ab7e..256036dbad 100644
--- a/tests/forms_tests/tests/tests.py
+++ b/tests/forms_tests/tests/tests.py
@@ -94,9 +94,9 @@ class ModelFormCallableModelDefault(TestCase):
def test_callable_initial_value(self):
"The initial value for a callable default returning a queryset is the pk (refs #13769)"
- obj1 = ChoiceOptionModel.objects.create(id=1, name='default')
- obj2 = ChoiceOptionModel.objects.create(id=2, name='option 2')
- obj3 = ChoiceOptionModel.objects.create(id=3, name='option 3')
+ ChoiceOptionModel.objects.create(id=1, name='default')
+ ChoiceOptionModel.objects.create(id=2, name='option 2')
+ ChoiceOptionModel.objects.create(id=3, name='option 3')
self.assertHTMLEqual(ChoiceFieldForm().as_p(), """