-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Make most fastparser errors non-fatal #2689
Conversation
Nice, but couldn't at least syntax errors in |
Yes, but I think that makes sense as a separate PR, as that decision takes place in a somewhat different part of the codebase. |
I think the other PR should be pretty simple, though. This one has enough going on already that I'd prefer to keep them separate. |
OK. I'll try to make time Monday to review this one. |
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 except for these nits.
if (len(func_type_ast.argtypes) == 1 and | ||
isinstance(func_type_ast.argtypes[0], ast35.Ellipsis)): | ||
arg_types = [a.type_annotation if a.type_annotation is not None else AnyType() | ||
for a in args] |
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.
Indent one more space. Also below on line 292.
for a in args] | ||
else: | ||
translated_args = (TypeConverter(self.errors, line=n.lineno) | ||
.translate_expr_list(func_type_ast.argtypes)) |
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.
Indent 3 more spaces.
self.fail('Type signature has too few arguments', n.lineno, 0) | ||
else: | ||
func_type = CallableType([a if a is not None else | ||
AnyType(implicit=True) for a in arg_types], |
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.
Indent two more spaces; indent the remaining line 1 more space.
raise TypeCommentParseError('Variable annotation syntax is only ' | ||
'suppoted in Python 3.6, use type ' | ||
'comment instead', n.lineno, n.col_offset) | ||
self.fail('Variable annotation syntax is only suppoted in Python 3.6, ' |
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.
typo: suppoted (and you'll have to fix a test in check-newsyntax.test to match the correct spelling :-).
Thanks for catching those nits! Not sure how that spacing got messed up... |
Instead of throwing an exception up to the parse function when encountering an error, the fast parser will now report it to the
errors
object and keep parsing. These errors are still considered blocking errors, so type checking will not continue past the parsing stage. This means that mypy will show you all your parse errors, instead of showing them to you one at a time as you fix them.Fixes #2685.