You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
W191: erroneously checks indentation within triple-quoted strings #376
@petere if you read the issue history in #45, you'll see that you can use # noqa at the end of the string to disable pep8 checks on it. That was added by #243 and that PR can probably be extended to this purpose but would at that point probably not work so well.
Apparently, #45 was closed because # noqa is considered to "fix" this issue. But that seems wrong, because it would also hide other issues in the same statement. Trivial example:
ifTrue:
print(""" tab at start of this line"""); # noqa
I think this issue (or another one like it) should be kept open until a proper fix is found.
Sure. I can tell you why it happens (those checks are done on physical rather than logical lines) but I haven't looked into or thought about exactly how to fix it. Again, I'd be happy to review a patch if you were to put one together. 😄
Thank you @IanLee1521 . I see where I went wrong. I copied the example into my editor to create a test and the editor changed the tab to 4 spaces. I will keep be extra careful to check for situations like this in the future.
I believe I have a patch for this issue, but it causes 5 tests to fail. In the first test below, the W191 is no longer emitted for the string containing a line which starts with a tab. The next two tests no longer emit E101 or W191, which is my understanding of what @petere desires as the resolution of this issue.
What should I do at this point? Should I submit a pull request with the tests failing?
First failing test
#: E101 E122 W191 W191
if True:
pass
change_2_log = \
"""Change 2 by slamb@testclient on 2006/04/13 21:46:23
creation
"""
p4change = {
2: change_2_log,
}
class TestP4Poller(unittest.TestCase):
def setUp(self):
self.setUpGetProcessOutput()
return self.setUpChangeSource()
def tearDown(self):
pass
Second failing test
#: E101 W191
if True:
print("""
tab at start of this line
""")
Third failing test
#: E101 W191
'''multiline string
with tabs
and spaces
'''
I believe I have a patch for this issue, but it causes 5 tests to fail. In the first test below, the W191 is no longer emitted for the string containing a line which starts with a tab. The next two tests no longer emit E101 or W191, which is my understanding of what @petere desires as the resolution of this issue.
changed the title [-]erroneously checks indentation within triple-quoted strings[/-][+]W191: erroneously checks indentation within triple-quoted strings[/+]on Jun 14, 2020
This is an issue for me where I have to align a multiline string with spaces as its printed in the console. But in a project that's tab-indented. Resulting in E101 errors.
Activity
myint commentedon Feb 1, 2015
I think this is a duplicate of #45.
petere commentedon Feb 2, 2015
Hmm, I suppose, but I don't understand why that issue was closed, since the problem wasn't fixed.
sigmavirus24 commentedon Feb 4, 2015
@petere if you read the issue history in #45, you'll see that you can use
# noqaat the end of the string to disable pep8 checks on it. That was added by #243 and that PR can probably be extended to this purpose but would at that point probably not work so well.IanLee1521 commentedon Feb 7, 2015
Hi @petere -- If you had a patch to change this, I'd be happy to review it.
petere commentedon Feb 8, 2015
Apparently, #45 was closed because
# noqais considered to "fix" this issue. But that seems wrong, because it would also hide other issues in the same statement. Trivial example:I think this issue (or another one like it) should be kept open until a proper fix is found.
IanLee1521 commentedon Feb 11, 2015
Sure. I can tell you why it happens (those checks are done on physical rather than logical lines) but I haven't looked into or thought about exactly how to fix it. Again, I'd be happy to review a patch if you were to put one together. 😄
arthall commentedon Jun 2, 2016
This appears to no longer be an issue. I ran pycodestyle as of commit fd4f1c2 on the example and no style violations were identified.
Added passing test case related to #376
IanLee1521 commentedon Jun 3, 2016
@arthall -- I created 8a93219 which as least highlights how the current behavior works (it does emit the errors as described in the original post).
arthall commentedon Jun 3, 2016
Thank you @IanLee1521 . I see where I went wrong. I copied the example into my editor to create a test and the editor changed the tab to 4 spaces. I will keep be extra careful to check for situations like this in the future.
IanLee1521 commentedon Jun 3, 2016
That's the same thing that happened to me. No worries!
arthall commentedon Jun 4, 2016
I believe I have a patch for this issue, but it causes 5 tests to fail. In the first test below, the W191 is no longer emitted for the string containing a line which starts with a tab. The next two tests no longer emit E101 or W191, which is my understanding of what @petere desires as the resolution of this issue.
What should I do at this point? Should I submit a pull request with the tests failing?
First failing test
Second failing test
Third failing test
Added passing test case related to #376
Added passing test case related to #376
spaceone commentedon Oct 29, 2016
This issue hits me, too.
JonathanRRogers commentedon Oct 18, 2018
Is the patch available somewhere, @arthall?
[-]erroneously checks indentation within triple-quoted strings[/-][+]W191: erroneously checks indentation within triple-quoted strings[/+]asottile commentedon Sep 22, 2021
this can also trigger E101
Zac-HD commentedon Sep 22, 2021
I reduced my example to the following case:
Avasam commentedon Sep 3, 2022
This is an issue for me where I have to align a multiline string with spaces as its printed in the console. But in a project that's tab-indented. Resulting in E101 errors.