8000 [2.2.x] Fixed E128, E741 flake8 warnings. · django/django@8301bc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8301bc9

Browse files
committed
[2.2.x] Fixed E128, E741 flake8 warnings.
Backport of 0668164 from master.
1 parent c7bab8d commit 8301bc9

File tree

11 files changed

+94
-78
lines changed

11 files changed

+94
-78
lines changed

django/contrib/admin/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ def message_user(self, request, message, level=messages.INFO, extra_tags='',
10661066
level = getattr(messages.constants, level.upper())
10671067
except AttributeError:
10681068
levels = messages.constants.DEFAULT_TAGS.values()
1069-
levels_repr = ', '.join('`%s`' % l for l in levels)
1069+
levels_repr = ', '.join('`%s`' % level for level in levels)
10701070
raise ValueError(
10711071
'Bad message level string: `%s`. Possible values are: %s'
10721072
% (level, levels_repr)

django/core/mail/message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def __setitem__(self, name, val):
172172
def set_payload(self, payload, charset=None):
173173
if charset == 'utf-8' and not isinstance(charset, Charset.Charset):
174174
has_long_lines = any(
175-
len(l.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT
176-
for l in payload.splitlines()
175+
len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT
176+
for line in payload.splitlines()
177177
)
178178
# Quoted-Printable encoding has the side effect of shortening long
179179
# lines, if any (#22561).

django/core/management/commands/compilemessages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def handle(self, **options):
9090
self.has_errors = False
9191
for basedir in basedirs:
9292
if locales:
93-
dirs = [os.path.join(basedir, l, 'LC_MESSAGES') for l in locales]
93+
dirs = [os.path.join(basedir, locale, 'LC_MESSAGES') for locale in locales]
9494
else:
9595
dirs = [basedir]
9696
locations = []

django/forms/widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def merge(*lists):
140140
except CyclicDependencyError:
141141
warnings.warn(
142142
'Detected duplicate Media files in an opposite order: {}'.format(
143-
', '.join(repr(l) for l in lists)
143+
', '.join(repr(list_) for list_ in lists)
144144
), MediaOrderConflictWarning,
145145
)
146146
return list(all_items)

django/http/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def _load_post_and_files(self):
327327

328328
def close(self):
329329
if hasattr(self, '_files'):
330-
for f in chain.from_iterable(l[1] for l in self._files.lists()):
330+
for f in chain.from_iterable(list_[1] for list_ in self._files.lists()):
331331
f.close()
332332

333333
# File-like and iterator interface.

django/utils/dateformat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def i(self):
123123
"Minutes; i.e. '00' to '59'"
124124
return '%02d' % self.data.minute
125125

126-
def O(self): # NOQA: E743
126+
def O(self): # NOQA: E743, E741
127127
"""
128128
Difference to Greenwich time in hours; e.g. '+0200', '-0430'.
129129
@@ -237,7 +237,7 @@ def F(self):
237237
"Month, textual, long; e.g. 'January'"
238238
return MONTHS[self.data.month]
239239

240-
def I(self): # NOQA: E743
240+
def I(self): # NOQA: E743, E741
241241
"'1' if Daylight Savings Time, '0' otherwise."
242242
try:
243243
if self.timezone and self.timezone.dst(self.data):
@@ -254,7 +254,7 @@ def j(self):
254254
"Day of the month without leading zeros; i.e. '1' to '31'"
255255
return self.data.day
256256

257-
def l(self): # NOQA: E743
257+
def l(self): # NOQA: E743, E741
258258
"Day of the week, textual, long; e.g. 'Friday'"
259259
return WEEKDAYS[self.data.weekday()]
260260

django/utils/topological_sort.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def topological_sort_as_sets(dependency_graph):
2727
todo.items() if node not in current}
2828

2929

30-
def stable_topological_sort(l, dependency_graph):
30+
def stable_topological_sort(nodes, dependency_graph):
3131
result = []
3232
for layer in topological_sort_as_sets(dependency_graph):
33-
for node in l:
33+
for node in nodes:
3434
if node in layer:
3535
result.append(node)
3636
return result

tests/gis_tests/geo3d/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _load_interstate_data(self):
7171
# Interstate (2D / 3D and Geographic/Projected variants)
7272
for name, line, exp_z in interstate_data:
7373
line_3d = GEOSGeometry(line, srid=4269)
74-
line_2d = LineString([l[:2] for l in line_3d.coords], srid=4269)
74+
line_2d = LineString([coord[:2] for coord in line_3d.coords], srid=4269)
7575

7676
# Creating a geographic and projected version of the
7777
# interstate in both 2D and 3D.

tests/gis_tests/geos_tests/test_geos.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,19 @@ def test_multipoints(self):
304304
def test_linestring(self):
305305
"Testing LineString objects."
306306
prev = fromstr('POINT(0 0)')
307-
for l in self.geometries.linestrings:
308-
ls = fromstr(l.wkt)
307+
for line in self.geometries.linestrings:
308+
ls = fromstr(line.wkt)
309309
self.assertEqual(ls.geom_type, 'LineString')
310310
self.assertEqual(ls.geom_typeid, 1)
311311
self.assertEqual(ls.dims, 1)
312312
self.assertIs(ls.empty, False)
313313
self.assertIs(ls.ring, False)
314-
if hasattr(l, 'centroid'):
315-
self.assertEqual(l.centroid, ls.centroid.tuple)
316-
if hasattr(l, 'tup'):
317-
self.assertEqual(l.tup, ls.tuple)
314+
if hasattr(line, 'centroid'):
315+
self.assertEqual(line.centroid, ls.centroid.tuple)
316+
if hasattr(line, 'tup'):
317+
self.assertEqual(line.tup, ls.tuple)
318318

319-
self.assertEqual(ls, fromstr(l.wkt))
319+
self.assertEqual(ls, fromstr(line.wkt))
320320
self.assertEqual(False, ls == prev) # Use assertEqual to test __eq__
321321
with self.assertRaises(IndexError):
322322
ls.__getitem__(len(ls))
@@ -351,16 +351,16 @@ def test_linestring(self):
351351
def test_multilinestring(self):
352352
"Testing MultiLineString objects."
353353
prev = fromstr('POINT(0 0)')
354-
for l in self.geometries.multilinestrings:
355-
ml = fromstr(l.wkt)
354+
for line in self.geometries.multilinestrings:
355+
ml = fromstr(line.wkt)
356356
self.assertEqual(ml.geom_type, 'MultiLineString')
357357
self.assertEqual(ml.geom_typeid, 5)
358358
self.assertEqual(ml.dims, 1)
359359

360-
self.assertAlmostEqual(l.centroid[0], ml.centroid.x, 9)
361-
self.assertAlmostEqual(l.centroid[1], ml.centroid.y, 9)
360+
self.assertAlmostEqual(line.centroid[0], ml.centroid.x, 9)
361+
self.assertAlmostEqual(line.centroid[1], ml.centroid.y, 9)
362362

363-
self.assertEqual(ml, fromstr(l.wkt))
363+
self.assertEqual(ml, fromstr(line.wkt))
364364
self.assertEqual(False, ml == prev) # Use assertEqual to test __eq__
365365
prev = ml
366366

tests/staticfiles_tests/test_management.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_all_files(self):
7171
findstatic returns all candidate files if run without --first and -v1.
7272
"""
7373
result = call_command('findstatic', 'test/file.txt', verbosity=1, stdout=StringIO())
74-
lines = [l.strip() for l in result.split('\n')]
74+
lines = [line.strip() for line in result.split('\n')]
7575
self.assertEqual(len(lines), 3) # three because there is also the "Found <file> here" line
7676
self.assertIn('project', lines[1])
7777
self.assertIn('apps', lines[2])
@@ -81,7 +81,7 @@ def test_all_files_less_verbose(self):
8181
findstatic returns all candidate files if run without --first and -v0.
8282
"""
8383
result = call_command('findstatic', 'test/file.txt', verbosity=0, stdout=StringIO())
84-
lines = [l.strip() for l in result.split('\n')]
84+
lines = [line.strip() for line in result.split('\n')]
8585
self.assertEqual(len(lines), 2)
8686
self.assertIn('project', lines[0])
8787
self.assertIn('apps', lines[1])
@@ -92,7 +92,7 @@ def test_all_files_more_verbose(self):
9292
Also, test that findstatic returns the searched locations with -v2.
9393
"""
9494
result = call_command('findstatic', 'test/file.txt', verbosity=2, stdout=StringIO())
95-
lines = [l.strip() for l in result.split('\n')]
95+
lines = [line.strip() for line in result.split('\n')]
9696
self.assertIn('project', lines[1])
9797
self.assertIn('apps', lines[2])
9898
self.assertIn("Looking in the following locations:", lines[3])

0 commit comments

Comments
 (0)
0