summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-05-30 10:57:15 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2012-05-30 10:57:15 +0200
commit8ce99000b498fa02099eb148f22c328b5ab12e02 (patch)
tree79b0e76b799b15a029a409f260c146bf1308b013
parent73566688362192418b646009b32b801cab5fe506 (diff)
downloadpep8-8ce99000b498fa02099eb148f22c328b5ab12e02.tar.gz
Chase some false positive indentation errors.
-rwxr-xr-xpep8.py11
-rw-r--r--testsuite/E12.py56
-rw-r--r--testsuite/E50.py4
3 files changed, 60 insertions, 11 deletions
diff --git a/pep8.py b/pep8.py
index 4ab3faa..e44ee4d 100755
--- a/pep8.py
+++ b/pep8.py
@@ -140,8 +140,8 @@ BINARY_OPERATORS = frozenset([
'%', '^', '&', '|', '=', '/', '//', '<', '>', '<<'])
UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
OPERATORS = BINARY_OPERATORS | UNARY_OPERATORS
-SKIP_TOKENS = frozenset([tokenize.COMMENT, tokenize.NL, tokenize.INDENT,
- tokenize.DEDENT, tokenize.NEWLINE])
+SKIP_TOKENS = frozenset([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE,
+ tokenize.INDENT, tokenize.DEDENT])
SINGLETONS = frozenset(['False', 'None', 'True'])
KEYWORDS = frozenset(keyword.kwlist + ['print']) - SINGLETONS
BENCHMARK_KEYS = ('directories', 'files', 'logical lines', 'physical lines')
@@ -502,7 +502,7 @@ def continuation_line_indentation(logical_line, tokens, indent_level):
# check that this line is either visually indented vs
# the opening parens, or a hanging indent.
- if start[1] in (last_token_multiline, start_col):
+ if last_token_multiline or start[1] == start_col:
# continuing right after a multiline string
# or if the line is visually indenting, it is fine.
pass
@@ -564,10 +564,7 @@ def continuation_line_indentation(logical_line, tokens, indent_level):
visual_min[depth] = parens[open_row][-1] + 1
assert len(visual_min) == depth + 1
- if start[0] == end[0]:
- last_token_multiline = None
- else:
- last_token_multiline = end[1]
+ last_token_multiline = (start[0] != end[0])
if indent_next and rel_indent[-1] == 4:
yield (last_indent, "E123 statement with indented block ends "
diff --git a/testsuite/E12.py b/testsuite/E12.py
index 80bd446..7998d4c 100644
--- a/testsuite/E12.py
+++ b/testsuite/E12.py
@@ -171,10 +171,6 @@ if foo is None and bar is "frop" and \
#: Okay
"""This is a multi-line
docstring."""
-##: E502
-#if (foo is None and bar is "e127" and \
-# blah == 'yeah'):
-# blah = 'yeahnah'
#: Okay
if blah:
# is this actually readable? :)
@@ -247,3 +243,55 @@ event_obj.write(cursor, user_id, {
'bbb': 2
}},
})
+##: E126
+#
+#
+#def qualify_by_address(self, cr, uid, ids, context=None,
+# params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
+# """ This gets called by the web server """
+#: E123
+
+
+def qualify_by_address(
+ self, cr, uid, ids, context=None,
+ params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
+ """ This gets called by the web server """
+#: Okay
+
+
+def qualify_by_address(
+ self, cr, uid, ids, context=None,
+ params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
+ """ This gets called by the web server """
+#: Okay
+_ipv4_re = re.compile('^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'
+ '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'
+ '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'
+ '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')
+
+#
+fct("""
+ AAA """ + status_2_string)
+
+#
+if context:
+ msg = """\
+action: GET-CONFIG
+payload:
+ ip_address: "%(ip)s"
+ username: "%(username)s"
+""" % context
+
+#
+if context:
+ msg = """\
+action: \
+GET-CONFIG
+""" % context
+#
+if context:
+ msg = """\
+action: """\
+"""GET-CONFIG
+""" % context
+#:
diff --git a/testsuite/E50.py b/testsuite/E50.py
index df30aee..1a7a996 100644
--- a/testsuite/E50.py
+++ b/testsuite/E50.py
@@ -7,6 +7,10 @@ a = ('123456789012345678901234567890123456789012345678901234567890123456789' \
a = ('AAA \
BBB' \
'CCC')
+#: E502
+if (foo is None and bar is "e000" and \
+ blah == 'yeah'):
+ blah = 'yeahnah'
#
#: Okay
a = ('AAA'