Skip to content

Conversation

kcaebe
Copy link
Contributor

@kcaebe kcaebe commented May 6, 2019

fixes #4103

@ilevkivskyi
Copy link
Member

You need to update existing tests. They are currently failing.

@gvanrossum
Copy link
Member

This is a good idea, but I'd like to see some tests (and the existing tests that are failing fixed). You also ought to add the same thing to fastparse2.py.

@@ -192,7 +192,8 @@ def parse_type_comment(type_comment: str,
typ = ast3_parse(type_comment, '<type_comment>', 'eval')
except SyntaxError as e:
if errors is not None:
errors.report(line, e.offset, TYPE_COMMENT_SYNTAX_ERROR, blocker=True)
err_msg = "{} '{}'".format(TYPE_COMMENT_SYNTAX_ERROR, type_comment)
Copy link
Member

Choose a reason for hiding this comment

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

I would strip everything in the type_comment after #, so that only the interesting part is shown.

file:2: error: syntax error in type comment
file:2: error: syntax error in type comment '*'

[case testInvalidTypeComment5
Copy link
Member

Choose a reason for hiding this comment

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

You have missing closing ] here in in couple tests below.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

LGTM now! I will merge when tests pass in CI.

@@ -337,6 +337,7 @@ def visit_FunctionDef(self, n: ast27.FunctionDef) -> Statement:
return_type = None
elif type_comment is not None and len(type_comment) > 0:
try:
print(type_comment)
Copy link
Member

Choose a reason for hiding this comment

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

Stray debugging print left.

@ilevkivskyi
Copy link
Member

Your last commit will likely cause many failures in CI (because at least some existing tests need to be updated). It is much easier to run tests locally first, since now the line in CI is really long, your PR might wait for an hour there.

@kcaebe
Copy link
Contributor Author

kcaebe commented May 6, 2019

I wanted to get the function annotations in the same PR so I'm okay with it taking a bit. Thanks for all the help @ilevkivskyi.

@ilevkivskyi ilevkivskyi merged commit 2c6cd83 into python:master May 6, 2019
@kcaebe kcaebe deleted the issue-4103 branch April 4, 2021 20:08
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.

When there's a syntax error, print the comment used
3 participants