-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fast parser: support @no_type_check, give better ellipses error #2722
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,11 +27,8 @@ | |
|
|
||
| # List of files that contain test case descriptions. | ||
| files = [ | ||
| 'check-columns.test', | ||
| 'check-expressions.test', | ||
| 'check-functions.test', | ||
| 'check-generic-subtyping.test', | ||
| 'check-tuples.test', | ||
| 'check-varargs.test', | ||
| ] | ||
| fast_parser_files = [ | ||
|
|
@@ -73,6 +70,9 @@ | |
| 'check-class-namedtuple.test', | ||
| 'check-selftype.test', | ||
| 'check-python2.test', | ||
| 'check-columns.test', | ||
| 'check-functions.test', | ||
| 'check-tuples.test', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cannot comment on lines 81 ('check-newsyntax.test') and 84 ('check-underscores.test'), but I think those two could be changed from
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch -- I'll do that in my next PR with the rest of the fixes. |
||
| ] | ||
|
|
||
| files.extend(fast_parser_files) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| # flags: --show-column-numbers | ||
| 1 + | ||
| [out] | ||
| main:2:3: error: Parse error before end of line | ||
| main:2:4: error: invalid syntax | ||
|
|
||
|
|
||
| [case testColumnsNestedFunctions] | ||
|
|
@@ -40,9 +40,9 @@ class A: | |
| pass | ||
| A().f() | ||
| A().f(1) | ||
| A().f('') # E:5: Argument 1 to "f" of "A" has incompatible type "str"; expected "int" | ||
| A().f(1, 1) # E:5: Argument 2 to "f" of "A" has incompatible type "int"; expected "str" | ||
| A().f(1, 'hello', 'hi') # E:5: Too many arguments for "f" of "A" | ||
| A().f('') # E:0: Argument 1 to "f" of "A" has incompatible type "str"; expected "int" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little sad that the column numbers are no longer correct. Can you file an issue to fix that later?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into this briefly, and it appeared that the parser just associates the wrong number with the call. Filed #2749 to look into it further. |
||
| A().f(1, 1) # E:0: Argument 2 to "f" of "A" has incompatible type "int"; expected "str" | ||
| A().f(1, 'hello', 'hi') # E:0: Too many arguments for "f" of "A" | ||
|
|
||
| [case testColumnsMultipleStatementsPerLine] | ||
| # flags: --show-column-numbers | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -387,7 +387,7 @@ aa, bb, *cc = t # E: Need type annotation for variable | |
| [case testAssignmentToStarAnnotation] | ||
| from typing import List | ||
| li, lo = None, None # type: List[int], List[object] | ||
| a, b, *c = 1, 2 # type: int, int, *List[int] | ||
| a, b, *c = 1, 2 # type: int, int, List[int] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, interesting. This is nowhere spelled out in PEP 484. But given that it was always
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is more correct too. |
||
| c = lo # E: Incompatible types in assignment (expression has type List[object], variable has type List[int]) | ||
| c = li | ||
| [builtins fixtures/list.pyi] | ||
|
|
||
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.
Sorry, I should have mentioned there's another like this in fastparse2.py.
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.
Oops, should've realized.