summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnastasia Morozova <scullyx13@yandex-team.ru>2012-12-08 22:41:38 +0400
committerAnastasia Morozova <scullyx13@yandex-team.ru>2012-12-08 22:41:38 +0400
commite38599b2d1ca37d55a283da5f2c66e4a52046494 (patch)
tree344fd00c0e4e453efb49b6298fbe340c6682b77d
parent7f2d5a3f561d48864211642097f05c6a5d2c2a55 (diff)
downloadpep8-e38599b2d1ca37d55a283da5f2c66e4a52046494.tar.gz
Fix E231 for nested dict
-rwxr-xr-xpep8.py4
-rw-r--r--testsuite/E23.py2
2 files changed, 5 insertions, 1 deletions
diff --git a/pep8.py b/pep8.py
index d57cdf3..157ee12 100755
--- a/pep8.py
+++ b/pep8.py
@@ -387,13 +387,15 @@ def missing_whitespace(logical_line):
Okay: a[1:4:2]
E231: ['a','b']
E231: foo(bar,baz)
+ E231: [{'a':'b'}]
"""
line = logical_line
for index in range(len(line) - 1):
char = line[index]
if char in ',;:' and line[index + 1] not in WHITESPACE:
before = line[:index]
- if char == ':' and before.count('[') > before.count(']'):
+ if char == ':' and before.count('[') > before.count(']') and \
+ before.count('{') == before.count('}'):
continue # Slice syntax, no space required
if char == ',' and line[index + 1] == ')':
continue # Allow tuple with only one element: (3,)
diff --git a/testsuite/E23.py b/testsuite/E23.py
index db1696e..f2fe1f0 100644
--- a/testsuite/E23.py
+++ b/testsuite/E23.py
@@ -2,6 +2,8 @@
a = (1,2)
#: E231
a[b1,:]
+#: E231
+a = [{'a':''}]
#: Okay
a = (4,)
b = (5, )