-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix indentation handling with tabs (Issue: #1148) #1947
Conversation
A Tab is not equal to 8 spaces. So just counting tabs as 8 spaces is wrong. Use the whole 'tabs' and/or 'spaces' string for indentation checks instead of some imaginary number of whitespaces.
I'm going try to get this merged.. Might take me awhile since I'm not familiar with this section of pylint |
@@ -0,0 +1,3 @@ | |||
[FORMAT] | |||
indent-string='\t' | |||
indent-after-paren=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Could you add a newline at the end of the file?: https://stackoverflow.com/questions/5813311/no-newline-at-end-of-file
pylint/checkers/format.py
Outdated
"""Return the indention string of the given line.""" | ||
result = '' | ||
for char in line: | ||
if char == ' ' or char == '\t': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement could be written as if char in '\t ':
(no need to change if you don't want to though)
|
||
def d(self, e): | ||
self.b( | ||
e) # [bad-continuation] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does line 24
raise bad-continuation but not 20
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh looks like this line has mixed tabs and spaces
pylint/checkers/format.py
Outdated
def line_indent(self, idx): | ||
return _get_indent_string(self.line(idx)) | ||
|
||
def token_indent(self, idx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add docstrings here explaining these methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for a few minor suggestions! Also don't forget to add yourself to the CONTRIBUTORS.txt
and mention what you've changed in ChangeLog
under 2.0
Nice work @x539 ! I'm glad to have this fixed |
A Tab is not equal to 8 spaces. So just counting tabs as 8 spaces is wrong.
Use the whole 'tabs' and/or 'spaces' string for indentation checks
instead of some imaginary number of whitespaces.
Fixes