diff options
author | Anthony Sottile <asottile@umich.edu> | 2017-03-15 08:37:40 -0700 |
---|---|---|
committer | Anthony Sottile <asottile@umich.edu> | 2017-03-15 08:38:39 -0700 |
commit | cb17d2739696df66c5b1eed2de559b4d778836e2 (patch) | |
tree | 9f715fa3e86740307e8388a72bb0200d5aaae75d | |
parent | f1908ba99b72c272720de067794cd3d1a88a1bbb (diff) | |
download | pep8-cb17d2739696df66c5b1eed2de559b4d778836e2.tar.gz |
Correctly report E501 when the first line of a docstring is too long
Resolves #622
-rwxr-xr-x | pycodestyle.py | 6 | ||||
-rw-r--r-- | testsuite/E50.py | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 5d8c2ac..556467b 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1199,7 +1199,7 @@ def comparison_type(logical_line, noqa): def bare_except(logical_line, noqa): - r"""When catching exceptions, mention specific exceptions whenever possible. + r"""When catching exceptions, mention specific exceptions when possible. Okay: except Exception: Okay: except BaseException: @@ -1727,7 +1727,9 @@ class Checker(object): return self.multiline = True self.line_number = token[2][0] - for line in token[1].split('\n')[:-1]: + _, src, (_, offset), _, _ = token + src = self.lines[self.line_number - 1][:offset] + src + for line in src.split('\n')[:-1]: self.check_physical(line + '\n') self.line_number += 1 self.multiline = False diff --git a/testsuite/E50.py b/testsuite/E50.py index f60f389..189f416 100644 --- a/testsuite/E50.py +++ b/testsuite/E50.py @@ -82,6 +82,11 @@ that I'm calling: #: E501 """ longnospaceslongnospaceslongnospaceslongnospaceslongnospaceslongnospaceslongnospaceslongnospaces""" +#: E501 +# Regression test for #622 +def foo(): + """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pulvinar vitae + """ #: Okay """ This |