Fix false positive E121/E126 with multi-line string; issue #265
authorFlorent Xicluna <florent.xicluna@gmail.com>
Wed, 2 Apr 2014 22:32:28 +0000 (00:32 +0200)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Wed, 2 Apr 2014 22:32:28 +0000 (00:32 +0200)
CHANGES.txt
pep8.py
testsuite/E12not.py
testsuite/test_shell.py

index 528cf0d9576c2c3ad0132f31e9498253e5314ee9..d710adf67dec71e89d64bb5aed18b07ef48b6490 100644 (file)
@@ -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)
diff --git a/pep8.py b/pep8.py
index dba59a0883f3d452200489ee3c7a16fe7800fd89..5529ca7072a2bd1c1e74e19301ec61423b67ac4d 100755 (executable)
--- a/pep8.py
+++ b/pep8.py
@@ -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:
index 733b424ee9fb1083c7ace2ff3f1d5a69bacb9be9..a53d9a4c37f975e3769942a43ab26aa66f6669af 100644 (file)
@@ -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
+    )
+)
index 0313c0c4a917d5998241558fb636f5891594ec04..66d41747bfeaac5632e1b5579b7951a82abd752b 100644 (file)
@@ -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 = ()