summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-06-16 00:37:18 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2012-06-16 00:37:18 +0200
commitbbeb3108464748f1646c331c15ca7a64b4583023 (patch)
tree4a20b911d4246f9fea37f847ddda9b97b1370634
parent715aec6377e5d62106a9e5a5f1289d0bd9f23cfe (diff)
downloadpep8-bbeb3108464748f1646c331c15ca7a64b4583023.tar.gz
Fix minor E12 glitches.
-rw-r--r--CHANGES.txt2
-rwxr-xr-xpep8.py16
-rw-r--r--testsuite/E12.py7
-rw-r--r--testsuite/E12not.py7
4 files changed, 24 insertions, 8 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 87efd72..d40efe3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,8 @@ Changelog
1.x (UNRELEASED)
----------------
+* Fix wrong or missing cases for the E12 series.
+
* Fix cases where E122 was missed. (Issue #81)
diff --git a/pep8.py b/pep8.py
index 9f7fb60..c8e3d40 100755
--- a/pep8.py
+++ b/pep8.py
@@ -513,9 +513,8 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose):
'indentation of opening bracket\'s line')
elif visual_indent is True:
# visual indent is verified
- if len(indent_chances) > 1:
+ if not indent[depth]:
indent[depth] = start[1]
- indent_chances = {start[1]: True}
elif visual_indent in (text, str):
# ignore token lined up with matching one from a previous line
pass
@@ -544,9 +543,8 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose):
indent_chances[start[1]] = True
if verbose >= 4:
print("bracket depth %s indent to %s" % (depth, start[1]))
-
# deal with implicit string concatenation
- if token_type == tokenize.STRING or text in ('u', 'ur', 'b', 'br'):
+ elif token_type == tokenize.STRING or text in ('u', 'ur', 'b', 'br'):
indent_chances[start[1]] = str
# keep track of bracket depth
@@ -564,8 +562,9 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose):
for d in range(depth):
if indent[d] > prev_indent:
indent[d] = 0
- if prev_indent in indent_chances:
- del indent_chances[prev_indent]
+ for ind in list(indent_chances):
+ if ind >= prev_indent:
+ del indent_chances[ind]
depth -= 1
if depth:
indent_chances[indent[depth]] = True
@@ -574,8 +573,9 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose):
parens[idx] -= 1
break
assert len(indent) == depth + 1
- # allow to line up tokens
- indent_chances[start[1]] = text
+ if start[1] not in indent_chances:
+ # allow to line up tokens
+ indent_chances[start[1]] = text
last_token_multiline = (start[0] != end[0])
diff --git a/testsuite/E12.py b/testsuite/E12.py
index 7b8313b..ffd2dda 100644
--- a/testsuite/E12.py
+++ b/testsuite/E12.py
@@ -156,6 +156,10 @@ print "hello", (
"there",
# "john",
"dude")
+#: E121
+part = set_mimetype((
+ a.get('mime_type', 'text')),
+ 'default')
#: E126
troublesome_hash = {
"hash": "value",
@@ -238,6 +242,9 @@ rv.update(d=('a', 'b', 'c'),
rv.update(d=('a' + 'b', 'c'),
e=42, f=42
+ 42)
+#: E127
+input1 = {'a': {'calc': 1 + 2}, 'b': 1
+ + 42}
#: E128
rv.update(d=('a' + 'b', 'c'),
e=42, f=(42
diff --git a/testsuite/E12not.py b/testsuite/E12not.py
index 29f6492..f32a03e 100644
--- a/testsuite/E12not.py
+++ b/testsuite/E12not.py
@@ -118,6 +118,13 @@ abricot = 3 + \
4 + \
5 + 6
+part = [-1, 2, 3,
+ 4, 5, 6]
+
+part = [-1, (2, 3,
+ 4, 5, 6), 7,
+ 8, 9, 0]
+
fnct(1, 2, 3,
4, 5, 6)