class MainFrame(object):
def init_ui(self):
self.m_notebook.ChangeSelection(
self.m_notebook.FindPage(self.m_panelComponents))
Note, the indentation is made via tabs, not spaces.
pylint.exe --indent-string='\t' --indent-after-paren=1 --reports=no test.pyC: 4, 0: Wrong hanging indentation (add 14 spaces).
self.m_notebook.FindPage(self.m_panelComponents))
^ | (bad-continuation)
Adding more tabs or spaces at the beginning of the hanging line doesn't help.
I would expect that pylint considers this hanging indentation correct. When the function is placed outside the class, the "Wrong hanging indentation" warning is not reported.
No config file found, using default configuration
pylint 1.6.4,
astroid 1.4.8
Python 2.7.8 (default, Jul 2 2014, 19:48:49) [MSC v.1500 64 bit (AMD64)]
Is duplicated https://github.com/PyCQA/pylint/issues/638?
I don't think it's identical, because
Another example of the same problem (of mine):
class FileProcessor(object):
def read_items(self):
return [
XItem(ITEM1),
XItem(ITEM4),
]
C: 4, 0: Wrong hanging indentation (add 14 spaces).
XItem(ITEM1),
^ | (bad-continuation)
C: 5, 0: Wrong hanging indentation (add 14 spaces).
XItem(ITEM4),
^ | (bad-continuation)
C: 6, 0: Wrong hanging indentation.
]
^ || (bad-continuation)
I'd say that the problem is caused by incorrect computation of indentation spaces in case of indentation by tabs.
pylint.exe --indent-string='\t' --indent-after-paren=1 --reports=no test.py
Pylint wants us to add 14 more spaces (Wrong hanging indentation (add 14 spaces)), three characters (tabs) are already present, which gives 17 expected characters in total. The actual number of spaces seen by pylint is: two tabs before return (in the second example), which pylint re-calculates to 16 spaces (2x8), plus 1 space comming from indent-after-paren; 17 chars in total again.
When indent-after-paren parameter is increased, the number of spaces pylint wants us to add is increased as well.
The correct computation should be as follows:
Pylint should expect two tabs (before return) plus one char (tab, or space?) for indent-after-paren, i.e. three tabs in total. And it should see three tabs, which is correct. In my opinion, tab should be treated as one character, not expanded to (8 or whatever number of) spaces.
But please, do not break the calculation of "continued indentation", which in case of tab indentation is done with spaces, and which works now:
class FileProcessor(object):
def read_items(self):
return [XItem(ITEM1),
XItem(ITEM4),
]
Thank you for providing this input, I will take a look when I will get some free time. If you want to try your hand at a patch, please feel free to do so.
+1
I've been annoyed by this warning as well so turned it off. But hanging indentation is a common problem so I'd like to have this as a part of my linting.
+1
+1
+1
It would be great to get the patch above applied to mainline...
+1. @x539, are you going to make a PR? @PCManticore any updates on this?
bad-continuation has been removed in #3571, black or another formatter can help you with this better than Pylint
Most helpful comment
+1
I've been annoyed by this warning as well so turned it off. But hanging indentation is a common problem so I'd like to have this as a part of my linting.