[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
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

fixed indicator position in code with tabs #8307

Merged
merged 2 commits into from Jan 22, 2020
Merged

Conversation

Copy link
Contributor

dosisod commented Jan 21, 2020

PR for issue #8306.

dosisod force-pushed the dosisod:master branch from b8be7aa to 34cacdd Jan 21, 2020

This comment has been minimized.

Copy link
Contributor Author

dosisod commented Jan 21, 2020

Now that the tests are actually failing for code related reasons, what is the suggested change for the 2 failing tests?

[case testParseErrorShowSource]
# flags: --pretty --show-error-codes
import a
a.f()
[file a.py]
def f() -> None: pass
[file a.py.2]
def f(x: int) ->
[file a.py.3]
def f(x: int) -> None: pass
[file a.py.4]
def f() -> None: pass
[out]
==
a.py:1: error: invalid syntax [syntax]
def f(x: int) ->
^
==
main:3: error: Too few arguments for "f" [call-arg]
a.f()
^
==

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?

Copy link
Collaborator

ilevkivskyi left a comment

Thanks, generally looks good, although I have one question.

@@ -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)

This comment has been minimized.

Copy link

ilevkivskyi Jan 21, 2020

Collaborator

Why not source_line.expandtabs()? (Also 8 is default for the latter.)

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))

This comment has been minimized.

Copy link

ilevkivskyi Jan 21, 2020

Collaborator

Same question here.

This comment has been minimized.

Copy link
Collaborator

ilevkivskyi commented Jan 21, 2020

The cursor is off by 1 character, though I would think that the new position of the cursor makes more sense.

This doesn't look important, you can just update the existing tests.

Also, where should I put new tests to check for consistency between tabs and spaces when pretty printing?

I would put them at the end of cmdline.test.

This comment has been minimized.

Copy link
Contributor Author

dosisod commented Jan 21, 2020

Did not know that expandtabs() existed. Changed that, then added and modified the tests.

Copy link
Collaborator

ilevkivskyi left a comment

LGTM now.

ilevkivskyi merged commit 0e8e135 into python:master Jan 22, 2020
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants