mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed E227 pep8 warnings
This commit is contained in:
parent
b289fcf1bf
commit
499cd912ca
@ -814,11 +814,11 @@ def filesizeformat(bytes):
|
|||||||
|
|
||||||
filesize_number_format = lambda value: formats.number_format(round(value, 1), 1)
|
filesize_number_format = lambda value: formats.number_format(round(value, 1), 1)
|
||||||
|
|
||||||
KB = 1<<10
|
KB = 1 << 10
|
||||||
MB = 1<<20
|
MB = 1 << 20
|
||||||
GB = 1<<30
|
GB = 1 << 30
|
||||||
TB = 1<<40
|
TB = 1 << 40
|
||||||
PB = 1<<50
|
PB = 1 << 50
|
||||||
|
|
||||||
if bytes < KB:
|
if bytes < KB:
|
||||||
value = ungettext("%(size)d byte", "%(size)d bytes", bytes) % {'size': bytes}
|
value = ungettext("%(size)d byte", "%(size)d bytes", bytes) % {'size': bytes}
|
||||||
|
@ -41,7 +41,7 @@ class Lexer(object):
|
|||||||
groupid = "t%d" % tok.id
|
groupid = "t%d" % tok.id
|
||||||
self.toks[groupid] = tok
|
self.toks[groupid] = tok
|
||||||
parts.append("(?P<%s>%s)" % (groupid, tok.regex))
|
parts.append("(?P<%s>%s)" % (groupid, tok.regex))
|
||||||
self.regexes[state] = re.compile("|".join(parts), re.MULTILINE|re.VERBOSE)
|
self.regexes[state] = re.compile("|".join(parts), re.MULTILINE | re.VERBOSE)
|
||||||
|
|
||||||
self.state = first
|
self.state = first
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ capfirst = lambda x: x and force_text(x)[0].upper() + force_text(x)[1:]
|
|||||||
capfirst = allow_lazy(capfirst, six.text_type)
|
capfirst = allow_lazy(capfirst, six.text_type)
|
||||||
|
|
||||||
# Set up regular expressions
|
# Set up regular expressions
|
||||||
re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U|re.S)
|
re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U | re.S)
|
||||||
re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S)
|
re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S)
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
|
|||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py
|
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py
|
||||||
ignore=E124,E125,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E227,E231,E261,E301,F401,F403,W601
|
ignore=E124,E125,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E231,E261,E301,F401,F403,W601
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
license-file = LICENSE
|
license-file = LICENSE
|
||||||
|
@ -1062,7 +1062,7 @@ class AggregationTests(TestCase):
|
|||||||
pk__in=Author.objects.annotate(book_cnt=Count('book')).filter(book_cnt=2)
|
pk__in=Author.objects.annotate(book_cnt=Count('book')).filter(book_cnt=2)
|
||||||
).order_by('name')
|
).order_by('name')
|
||||||
expected_results = [a.name for a in expected_results]
|
expected_results = [a.name for a in expected_results]
|
||||||
qs = Author.objects.annotate(book_cnt=Count('book')).exclude(Q(book_cnt=2)|Q(book_cnt=2)).order_by('name')
|
qs = Author.objects.annotate(book_cnt=Count('book')).exclude(Q(book_cnt=2) | Q(book_cnt=2)).order_by('name')
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
qs,
|
qs,
|
||||||
expected_results,
|
expected_results,
|
||||||
@ -1071,7 +1071,7 @@ class AggregationTests(TestCase):
|
|||||||
|
|
||||||
def test_name_filters(self):
|
def test_name_filters(self):
|
||||||
qs = Author.objects.annotate(Count('book')).filter(
|
qs = Author.objects.annotate(Count('book')).filter(
|
||||||
Q(book__count__exact=2)|Q(name='Adrian Holovaty')
|
Q(book__count__exact=2) | Q(name='Adrian Holovaty')
|
||||||
).order_by('name')
|
).order_by('name')
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
qs,
|
qs,
|
||||||
@ -1084,7 +1084,7 @@ class AggregationTests(TestCase):
|
|||||||
# Note that Adrian's age is 34 in the fixtures, and he has one book
|
# Note that Adrian's age is 34 in the fixtures, and he has one book
|
||||||
# so both conditions match one author.
|
# so both conditions match one author.
|
||||||
qs = Author.objects.annotate(Count('book')).filter(
|
qs = Author.objects.annotate(Count('book')).filter(
|
||||||
Q(name='Peter Norvig')|Q(age=F('book__count') + 33)
|
Q(name='Peter Norvig') | Q(age=F('book__count') + 33)
|
||||||
).order_by('name')
|
).order_by('name')
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
qs,
|
qs,
|
||||||
|
@ -134,7 +134,7 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
['<Item: one>']
|
['<Item: one>']
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Item.objects.filter(Q(tags=self.t1)).filter(Q(creator__name='fred')|Q(tags=self.t2)),
|
Item.objects.filter(Q(tags=self.t1)).filter(Q(creator__name='fred') | Q(tags=self.t2)),
|
||||||
['<Item: one>']
|
['<Item: one>']
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Item.objects.filter(Q(tags=self.t1), Q(creator__name='fred')|Q(tags=self.t2)),
|
Item.objects.filter(Q(tags=self.t1), Q(creator__name='fred') | Q(tags=self.t2)),
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
# (which would match everything).
|
# (which would match everything).
|
||||||
self.assertQuerysetEqual(Author.objects.filter(Q(id__in=[])), [])
|
self.assertQuerysetEqual(Author.objects.filter(Q(id__in=[])), [])
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Author.objects.filter(Q(id__in=[])|Q(id__in=[])),
|
Author.objects.filter(Q(id__in=[]) | Q(id__in=[])),
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
# values (Author -> ExtraInfo, in the following), it should never be
|
# values (Author -> ExtraInfo, in the following), it should never be
|
||||||
# promoted to a left outer join. So the following query should only
|
# promoted to a left outer join. So the following query should only
|
||||||
# involve one "left outer" join (Author -> Item is 0-to-many).
|
# involve one "left outer" join (Author -> Item is 0-to-many).
|
||||||
qs = Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1)|Q(item__note=self.n3))
|
qs = Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1) | Q(item__note=self.n3))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len([x[2] for x in qs.query.alias_map.values() if x[2] == query.LOUTER and qs.query.alias_refcount[x[1]]]),
|
len([x[2] for x in qs.query.alias_map.values() if x[2] == query.LOUTER and qs.query.alias_refcount[x[1]]]),
|
||||||
1
|
1
|
||||||
@ -474,7 +474,7 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
|
|
||||||
def test_ticket3037(self):
|
def test_ticket3037(self):
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Item.objects.filter(Q(creator__name='a3', name='two')|Q(creator__name='a4', name='four')),
|
Item.objects.filter(Q(creator__name='a3', name='two') | Q(creator__name='a4', name='four')),
|
||||||
['<Item: four>']
|
['<Item: four>']
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -536,11 +536,11 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
# Multiple filter statements are joined using "AND" all the time.
|
# Multiple filter statements are joined using "AND" all the time.
|
||||||
|
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1)|Q(item__note=self.n3)),
|
Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1) | Q(item__note=self.n3)),
|
||||||
['<Author: a1>']
|
['<Author: a1>']
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Author.objects.filter(Q(extra__note=self.n1)|Q(item__note=self.n3)).filter(id=self.a1.id),
|
Author.objects.filter(Q(extra__note=self.n1) | Q(item__note=self.n3)).filter(id=self.a1.id),
|
||||||
['<Author: a1>']
|
['<Author: a1>']
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -830,23 +830,23 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
# Complex combinations of conjunctions, disjunctions and nullable
|
# Complex combinations of conjunctions, disjunctions and nullable
|
||||||
# relations.
|
# relations.
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Author.objects.filter(Q(item__note__extrainfo=self.e2)|Q(report=self.r1, name='xyz')),
|
Author.objects.filter(Q(item__note__extrainfo=self.e2) | Q(report=self.r1, name='xyz')),
|
||||||
['<Author: a2>']
|
['<Author: a2>']
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Author.objects.filter(Q(report=self.r1, name='xyz')|Q(item__note__extrainfo=self.e2)),
|
Author.objects.filter(Q(report=self.r1, name='xyz') | Q(item__note__extrainfo=self.e2)),
|
||||||
['<Author: a2>']
|
['<Author: a2>']
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Annotation.objects.filter(Q(tag__parent=self.t1)|Q(notes__note='n1', name='a1')),
|
Annotation.objects.filter(Q(tag__parent=self.t1) | Q(notes__note='n1', name='a1')),
|
||||||
['<Annotation: a1>']
|
['<Annotation: a1>']
|
||||||
)
|
)
|
||||||
xx = ExtraInfo.objects.create(info='xx', note=self.n3)
|
xx = ExtraInfo.objects.create(info='xx', note=self.n3)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Note.objects.filter(Q(extrainfo__author=self.a1)|Q(extrainfo=xx)),
|
Note.objects.filter(Q(extrainfo__author=self.a1) | Q(extrainfo=xx)),
|
||||||
['<Note: n1>', '<Note: n3>']
|
['<Note: n1>', '<Note: n3>']
|
||||||
)
|
)
|
||||||
q = Note.objects.filter(Q(extrainfo__author=self.a1)|Q(extrainfo=xx)).query
|
q = Note.objects.filter(Q(extrainfo__author=self.a1) | Q(extrainfo=xx)).query
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len([x[2] for x in q.alias_map.values() if x[2] == q.LOUTER and q.alias_refcount[x[1]]]),
|
len([x[2] for x in q.alias_map.values() if x[2] == q.LOUTER and q.alias_refcount[x[1]]]),
|
||||||
1
|
1
|
||||||
@ -872,11 +872,11 @@ class Queries1Tests(BaseQuerysetTest):
|
|||||||
Item.objects.exclude(tags__name='t4'),
|
Item.objects.exclude(tags__name='t4'),
|
||||||
[repr(i) for i in Item.objects.filter(~Q(tags__name='t4'))])
|
[repr(i) for i in Item.objects.filter(~Q(tags__name='t4'))])
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Item.objects.exclude(Q(tags__name='t4')|Q(tags__name='t3')),
|
Item.objects.exclude(Q(tags__name='t4') | Q(tags__name='t3')),
|
||||||
[repr(i) for i in Item.objects.filter(~(Q(tags__name='t4')|Q(tags__name='t3')))])
|
[repr(i) for i in Item.objects.filter(~(Q(tags__name='t4') | Q(tags__name='t3')))])
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Item.objects.exclude(Q(tags__name='t4')|~Q(tags__name='t3')),
|
Item.objects.exclude(Q(tags__name='t4') | ~Q(tags__name='t3')),
|
||||||
[repr(i) for i in Item.objects.filter(~(Q(tags__name='t4')|~Q(tags__name='t3')))])
|
[repr(i) for i in Item.objects.filter(~(Q(tags__name='t4') | ~Q(tags__name='t3')))])
|
||||||
|
|
||||||
def test_nested_exclude(self):
|
def test_nested_exclude(self):
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
@ -1318,7 +1318,7 @@ class Queries4Tests(BaseQuerysetTest):
|
|||||||
Report.objects.create(name='r4', creator=self.a1)
|
Report.objects.create(name='r4', creator=self.a1)
|
||||||
q1 = Author.objects.filter(report__name='r5')
|
q1 = Author.objects.filter(report__name='r5')
|
||||||
q2 = Author.objects.filter(report__name='r4').filter(report__name='r1')
|
q2 = Author.objects.filter(report__name='r4').filter(report__name='r1')
|
||||||
combined = q1|q2
|
combined = q1 | q2
|
||||||
self.assertEqual(str(combined.query).count('JOIN'), 2)
|
self.assertEqual(str(combined.query).count('JOIN'), 2)
|
||||||
self.assertEqual(len(combined), 1)
|
self.assertEqual(len(combined), 1)
|
||||||
self.assertEqual(combined[0].name, 'a1')
|
self.assertEqual(combined[0].name, 'a1')
|
||||||
@ -1606,11 +1606,11 @@ class Queries5Tests(TestCase):
|
|||||||
['<Note: n1>', '<Note: n2>']
|
['<Note: n1>', '<Note: n2>']
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Note.objects.filter(~Q()|~Q()),
|
Note.objects.filter(~Q() | ~Q()),
|
||||||
['<Note: n1>', '<Note: n2>']
|
['<Note: n1>', '<Note: n2>']
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Note.objects.exclude(~Q()&~Q()),
|
Note.objects.exclude(~Q() & ~Q()),
|
||||||
['<Note: n1>', '<Note: n2>']
|
['<Note: n1>', '<Note: n2>']
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1692,18 +1692,18 @@ class DisjunctiveFilterTests(TestCase):
|
|||||||
LeafA.objects.create(data='first')
|
LeafA.objects.create(data='first')
|
||||||
self.assertQuerysetEqual(LeafA.objects.all(), ['<LeafA: first>'])
|
self.assertQuerysetEqual(LeafA.objects.all(), ['<LeafA: first>'])
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
LeafA.objects.filter(Q(data='first')|Q(join__b__data='second')),
|
LeafA.objects.filter(Q(data='first') | Q(join__b__data='second')),
|
||||||
['<LeafA: first>']
|
['<LeafA: first>']
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_ticket8283(self):
|
def test_ticket8283(self):
|
||||||
# Checking that applying filters after a disjunction works correctly.
|
# Checking that applying filters after a disjunction works correctly.
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
(ExtraInfo.objects.filter(note=self.n1)|ExtraInfo.objects.filter(info='e2')).filter(note=self.n1),
|
(ExtraInfo.objects.filter(note=self.n1) | ExtraInfo.objects.filter(info='e2')).filter(note=self.n1),
|
||||||
['<ExtraInfo: e1>']
|
['<ExtraInfo: e1>']
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
(ExtraInfo.objects.filter(info='e2')|ExtraInfo.objects.filter(note=self.n1)).filter(note=self.n1),
|
(ExtraInfo.objects.filter(info='e2') | ExtraInfo.objects.filter(note=self.n1)).filter(note=self.n1),
|
||||||
['<ExtraInfo: e1>']
|
['<ExtraInfo: e1>']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user