-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fixed indicator position in code with tabs #8307
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
Conversation
Now that the tests are actually failing for code related reasons, what is the suggested change for the 2 failing tests? mypy/test-data/unit/fine-grained-blockers.test Lines 27 to 48 in 5d8c0cd
The cursor is off by 1 character, though I would think that the new position of the cursor makes more sense. Also, where should I put new tests to check for consistency between tabs and spaces when pretty printing? |
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.
Thanks, generally looks good, although I have one question.
mypy/errors.py
Outdated
@@ -451,12 +451,17 @@ def format_messages(self, error_info: List[ErrorInfo], | |||
# Add source code fragment and a location marker. | |||
if severity == 'error' and source_lines and line > 0: | |||
source_line = source_lines[line - 1] | |||
source_line_expanded = source_line.replace('\t', ' ' * 8) |
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 not source_line.expandtabs()
? (Also 8 is default for the latter.)
mypy/errors.py
Outdated
if column < 0: | ||
# Something went wrong, take first non-empty column. | ||
column = len(source_line) - len(source_line.lstrip()) | ||
|
||
# Shifts column after tab expansion | ||
column = len(source_line[:column].replace('\t', ' ' * 8)) |
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.
Same question here.
This doesn't look important, you can just update the existing tests.
I would put them at the end of |
Did not know that |
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.
LGTM now.
PR for issue #8306.