diff options
author | Anastasia Morozova <scullyx13@yandex-team.ru> | 2012-12-08 22:41:38 +0400 |
---|---|---|
committer | Anastasia Morozova <scullyx13@yandex-team.ru> | 2012-12-08 22:41:38 +0400 |
commit | e38599b2d1ca37d55a283da5f2c66e4a52046494 (patch) | |
tree | 344fd00c0e4e453efb49b6298fbe340c6682b77d | |
parent | 7f2d5a3f561d48864211642097f05c6a5d2c2a55 (diff) | |
download | pep8-e38599b2d1ca37d55a283da5f2c66e4a52046494.tar.gz |
Fix E231 for nested dict
-rwxr-xr-x | pep8.py | 4 | ||||
-rw-r--r-- | testsuite/E23.py | 2 |
2 files changed, 5 insertions, 1 deletions
@@ -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, ) |