Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pep8 raises "E111" even for "commented blocks" #426

Closed
ghost opened this issue Jul 31, 2015 · 5 comments
Closed

pep8 raises "E111" even for "commented blocks" #426

ghost opened this issue Jul 31, 2015 · 5 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jul 31, 2015

Hi,
I find this strange that pep8 raises "E111: indentation is not a multiple of four" even for commented blocks of script e.g.

-some code followed by commented block-

 # def test():

 #   print "just a test example

I was expecting "pep8" to ignore commented blocks.

@IanLee1521
Copy link
Member

Can you possibly share some more context? At least from what you quoted above, the comments are indented by one space each? That should be what pep8 is complaining about (the comments need to be indented by a multiple of four).

    # comment in by four
xxxx

@ghost
Copy link
Author

ghost commented Jul 31, 2015

I have a script with some blocks commented as shown below:

# @allowHookSkip
# def checkLongLine(ui, repo, **kwargs):
 #   #'''Prevent the usage of lines more than 140 chars in Acc'''
  #  for diff in repo['tip'].diff():
   #     for line in diff.split('\n'):
    #        if len(line) > 140 and line.startswith('+'):
    #           print 'More than 140 chars in line: %3s'%line
    #          return True

# @allowHookSkip
# def checkTrailingWhitespaces(ui, repo, **kwargs):
 #   '''Prevent the use of trailing whitespaces'''
  #  for diff in repo['tip'].diff():
   #     for line in diff.split('\n'):
    #        if line.rstrip()!=line and line.strip() and line.startswith('+'):
    #           print 'Trailing-Whitespace in line: %r'%line
    #          return True

Now when I am running pep8 on this script it raises "E111" error. Apparently commented blocks ain't aligned as shown but they are commented. Isn't it expected that if a line is commented then pep8 should ignore it?

@sigmavirus24
Copy link
Member

So I normally do

# @allowHookSkip
# def checkLongLine(ui, repo, **kwargs):
#    '''Prevent the usage of lines more than 140 chars in Acc'''
#    for diff in repo['tip'].diff():
#        for line in diff.split('\n'):
#            if len(line) > 140 and line.startswith('+'):
#               print 'More than 140 chars in line: %3s'%line
#               return True

And pep8 never complains. That said, comments are not auto-ignored by pep8 nor do I believe they should be.

@IanLee1521
Copy link
Member

Ah, no, your comments also need to be aligned to multiples of four spaces. e.g.:

# @allowHookSkip
# def checkLongLine(ui, repo, **kwargs):
#     #'''Prevent the usage of lines more than 140 chars in Acc'''
#     for diff in repo['tip'].diff():
#         for line in diff.split('\n'):
#             if len(line) > 140 and line.startswith('+'):
#                 print 'More than 140 chars in line: %3s'%line
#             return True

# @allowHookSkip
# def checkTrailingWhitespaces(ui, repo, **kwargs):
#     '''Prevent the use of trailing whitespaces'''
#     for diff in repo['tip'].diff():
#         for line in diff.split('\n'):
#             if line.rstrip()!=line and line.strip() and line.startswith('+'):
#                 print 'Trailing-Whitespace in line: %r'%line
#             return True

@ghost
Copy link
Author

ghost commented Aug 1, 2015

Thanks for clearing my doubt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants