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

Fix indentation handling with tabs (Issue: #1148) #1947

Merged
merged 5 commits into from Mar 25, 2018

Conversation

x539
Copy link

@x539 x539 commented Mar 16, 2018

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

@coveralls
Copy link

coveralls commented Mar 16, 2018

Coverage Status

Coverage increased (+0.007%) to 89.11% when pulling deaae61 on x539:issue/1148 into 03aa4ca on PyCQA:master.

@x539 x539 changed the title Fix indentation handling with tabs (Issue: #1148) WIP: Fix indentation handling with tabs (Issue: #1148) Mar 17, 2018
Andreas Freimuth added 3 commits March 17, 2018 23:54
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.
@x539 x539 changed the title WIP: Fix indentation handling with tabs (Issue: #1148) Fix indentation handling with tabs (Issue: #1148) Mar 17, 2018
@brycepg
Copy link
Contributor

brycepg commented Mar 21, 2018

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
Copy link
Contributor

@brycepg brycepg Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""Return the indention string of the given line."""
result = ''
for char in line:
if char == ' ' or char == '\t':
Copy link
Contributor

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]
Copy link
Contributor

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?

Copy link
Contributor

@brycepg brycepg Mar 21, 2018

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

def line_indent(self, idx):
return _get_indent_string(self.line(idx))

def token_indent(self, idx):
Copy link
Contributor

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?

Copy link
Contributor

@brycepg brycepg left a 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

@brycepg
Copy link
Contributor

brycepg commented Mar 25, 2018

Nice work @x539 ! I'm glad to have this fixed

@brycepg brycepg merged commit 18f9131 into pylint-dev:master Mar 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants