diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-04-03 00:32:28 +0200 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-04-03 00:32:28 +0200 |
commit | f01edd687c32d457a7961e048f7068c96b20d8ea (patch) | |
tree | af69fbf4968e51a2c0b056956e90d74644b8381e | |
parent | d0df292cb78cbd565d96cbfc92baa42cd85b3015 (diff) | |
download | pep8-f01edd687c32d457a7961e048f7068c96b20d8ea.tar.gz |
Fix false positive E121/E126 with multi-line string; issue #265
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rwxr-xr-x | pep8.py | 2 | ||||
-rw-r--r-- | testsuite/E12not.py | 12 | ||||
-rw-r--r-- | testsuite/test_shell.py | 8 |
4 files changed, 20 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 528cf0d..d710adf 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,7 +5,7 @@ Changelog 1.5.x (unreleased) ------------------ - +* Fix false positive E121/E126 with multi-line strings. (Issue #265) 1.5.1 (2014-03-27) @@ -556,6 +556,8 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing, indent_chances[start[1]] = text last_token_multiline = (start[0] != end[0]) + if last_token_multiline: + rel_indent[end[0] - first_row] = rel_indent[row] if indent_next and expand_indent(line) == indent_level + 4: if visual_indent: diff --git a/testsuite/E12not.py b/testsuite/E12not.py index 733b424..a53d9a4 100644 --- a/testsuite/E12not.py +++ b/testsuite/E12not.py @@ -632,3 +632,15 @@ some_hash = { else 0, } # +from textwrap import dedent + + +print dedent( + ''' + mkdir -p ./{build}/ + mv ./build/ ./{build}/%(revision)s/ + '''.format( + build='build', + # more stuff + ) +) diff --git a/testsuite/test_shell.py b/testsuite/test_shell.py index 0313c0c..66d4174 100644 --- a/testsuite/test_shell.py +++ b/testsuite/test_shell.py @@ -82,9 +82,11 @@ class ShellTestCase(unittest.TestCase): self.assertEqual(x, str(num)) self.assertEqual(y, str(col)) self.assertTrue(msg.startswith(' E11')) - # Config file read from the pep8's tox.ini - (config_filename,) = self._config_filenames - self.assertTrue(config_filename.endswith('tox.ini')) + # Config file read from the pep8's setup.cfg or tox.ini + config_filenames = self._config_filenames + self.assertEqual(len(config_filenames), 2) + self.assertTrue(config_filenames[0].endswith('setup.cfg')) + self.assertTrue(config_filenames[1].endswith('tox.ini')) def test_check_stdin(self): pep8.PROJECT_CONFIG = () |