Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d81aad4
[WIP] Make native parser the default
ilevkivskyi Aug 9, 2026
049c5fe
Also update parse error test output
ilevkivskyi Aug 9, 2026
9511035
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Aug 18, 2026
86a897a
Re-enable and update some more tests
ilevkivskyi Aug 19, 2026
a74105a
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Aug 25, 2026
6bebea2
Fix args parsing; update couple tests
ilevkivskyi Aug 25, 2026
68f2051
Fix/update some more tests
ilevkivskyi Sep 1, 2026
d7c282e
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Sep 2, 2026
1108dda
Update few more tests
ilevkivskyi Sep 2, 2026
199f613
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Sep 6, 2026
938a82a
Update some more tests
ilevkivskyi Sep 6, 2026
1ec9337
Update some parse error tests (run on 3.10 only)
ilevkivskyi Sep 6, 2026
b81937c
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Sep 7, 2026
0cbdf19
Update more tests (hopefully just one more left)
ilevkivskyi Sep 7, 2026
d60dcdb
Fix star-unpack version check
ilevkivskyi Sep 7, 2026
e445f9c
Try running parse tests on current Python version
ilevkivskyi Sep 7, 2026
322bfe5
Debug Windows newline issue (sorry for the noise)
ilevkivskyi Sep 8, 2026
fde2f8c
[WIP] Compare with interpreted mode
ilevkivskyi Sep 8, 2026
41da5d8
Revert "[WIP] Compare with interpreted mode"
ilevkivskyi Sep 8, 2026
432e7cb
Revert "Debug Windows newline issue (sorry for the noise)"
ilevkivskyi Sep 8, 2026
2d85a55
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Sep 8, 2026
443151a
Skip couple more tests
ilevkivskyi Sep 8, 2026
b721bdd
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Sep 9, 2026
cbecee8
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Sep 13, 2026
a612063
Update test
ilevkivskyi Sep 13, 2026
9ce726e
Merge remote-tracking branch 'upstream/master' into default-native-pa…
ilevkivskyi Sep 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Also update parse error test output
  • Loading branch information
ilevkivskyi committed Aug 9, 2026
commit 049c5fe32c3730efbfed49d242f0d2ae35292df1
6 changes: 6 additions & 0 deletions mypy/test/testparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from mypy.parse import parse
from mypy.test.data import DataDrivenTestCase, DataSuite
from mypy.test.helpers import assert_string_arrays_equal, find_test_files, parse_options
from mypy.test.update_data import update_testcase_output
from mypy.util import get_mypy_comments


Expand Down Expand Up @@ -115,6 +116,11 @@ def test_parse_error(testcase: DataDrivenTestCase) -> None:
except CompileError as e:
if e.module_with_blocker is not None:
assert e.module_with_blocker == "__main__"

# This may not work perfectly, since it was designed for testcheck.py, use with care.
if testcase.output != e.messages and testcase.config.getoption("--update-data", False):
update_testcase_output(testcase, e.messages, incremental_step=1)

# Verify that there was a compile error and that the error messages
# are equivalent.
assert_string_arrays_equal(
Expand Down
100 changes: 59 additions & 41 deletions test-data/unit/parse-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,96 +18,102 @@ file:1: error: Expected ':'
1
2
[out]
file:2: error: Unexpected indent
file:2: error: Unexpected indentation
file:2: error: Expected a statement

[case testInconsistentIndent]
if x:
1
1
[out]
file:3: error: Unexpected indent
file:3: error: Unexpected indentation
file:3: error: Expected a statement

[case testInconsistentIndent2]
if x:
1
1
[out]
file:3: error: Unindent does not match any outer indentation level
file:3: error: Expected dedent, found end of file

[case testInvalidBinaryOp]
1>
a*
a+1*
[out]
file:1: error: Invalid syntax
file:1: error: Expected an expression
file:2: error: Expected an expression
file:3: error: Expected an expression

[case testDoubleStar]
**a
[out]
file:1: error: Invalid syntax
file:1: error: Expected an expression

[case testMissingSuperClass]
class A(:
pass
[out]
file:1: error: Invalid syntax
file:1: error: Expected an expression or a ')'
file:1: error: Expected `)`, found newline

[case testUnexpectedEof]
if 1:
[out]
file:1: error: Expected an indented block after 'if' statement on line 1
file:1: error: Expected an indented block after `if` statement

[case testInvalidKeywordArguments1]
f(x=y, z)
[out]
file:1: error: Positional argument follows keyword argument
file:1: error: Positional argument cannot follow keyword argument

[case testInvalidKeywordArguments2]
f(**x, y)
[out]
file:1: error: Positional argument follows keyword argument unpacking
file:1: error: Positional argument cannot follow keyword argument unpacking

[case testInvalidBareAsteriskAndVarArgs2]
def f(*x: A, *) -> None: pass
[out]
file:1: error: Invalid syntax
file:1: error: Keyword-only parameter separator not allowed after '*' parameter

[case testInvalidBareAsteriskAndVarArgs3]
def f(*, *x: A) -> None: pass
[out]
file:1: error: Invalid syntax
file:1: error: Only one '*' parameter allowed

[case testInvalidBareAsteriskAndVarArgs4]
def f(*, **x: A) -> None: pass
[out]
file:1: error: Named arguments must follow bare *
file:1: error: Expected one or more keyword parameter after `*` separator

[case testInvalidBareAsterisk1]
def f(*) -> None: pass
[out]
file:1: error: Named arguments must follow bare *
file:1: error: Expected one or more keyword parameter after `*` separator

[case testInvalidBareAsterisk2]
def f(x, *) -> None: pass
[out]
file:1: error: Named arguments must follow bare *
file:1: error: Expected one or more keyword parameter after `*` separator

[case testInvalidFuncDefArgs1]
def f(x = y, x): pass
[out]
file:1: error: Non-default argument follows default argument
file:1: error: Parameter without a default cannot follow a parameter with a default

[case testInvalidFuncDefArgs3]
def f(**x, y):
pass
[out]
file:1: error: Invalid syntax
file:1: error: Parameter cannot follow var-keyword parameter

[case testInvalidFuncDefArgs4]
def f(**x, y=x):
pass
[out]
file:1: error: Invalid syntax
file:1: error: Parameter cannot follow var-keyword parameter

[case testInvalidTypeComment]
0
Expand Down Expand Up @@ -154,7 +160,7 @@ file:2: error: Syntax error in type comment "A B"
[case testMissingBracket]
def foo(
[out]
file:1: error: '(' was never closed
file:1: error: Unexpected EOF while parsing

[case testInvalidSignatureInComment1]
def f(): # type: x
Expand Down Expand Up @@ -203,7 +209,7 @@ file:1: error: Syntax error in type comment "(x) -"
def f(): # type: (x) ->
pass
[out]
file:1: error: Syntax error in type comment "(x) ->"
file:1: error: Type signature has too many parameters

[case testInvalidSignatureInComment9]
def f(): # type: (x) -> .
Expand Down Expand Up @@ -281,96 +287,103 @@ file:3: error: Inconsistent use of "**" in function signature
[case testPrintStatementInPython3]
print 1
[out]
file:1: error: Missing parentheses in call to 'print'. Did you mean print(...)?
file:1: error: Simple statements must be separated by newlines or semicolons

[case testInvalidConditionInConditionalExpression]
1 if 2, 3 else 4
[out]
file:1: error: Expected 'else' after 'if' expression
file:1: error: Expected `else`, found `,`
file:1: error: Expected a statement

[case testInvalidConditionInConditionalExpression2]
1 if x for y in z else 4
[out]
file:1: error: Expected 'else' after 'if' expression
file:1: error: Expected `else`, found `for`
file:1: error: Simple statements must be separated by newlines or semicolons
file:1: error: Expected a statement

[case testInvalidConditionInConditionalExpression3]
1 if x else for y in z
[out]
file:1: error: Invalid syntax
file:1: error: Expected an identifier, but found a keyword `for` that cannot be used here
file:1: error: Simple statements must be separated by newlines or semicolons

[case testYieldFromNotRightParameter]
def f():
yield from
[out]
file:2: error: Invalid syntax
file:2: error: Expected an expression

[case testYieldFromAfterReturn]
def f():
return yield from h()
[out]
file:2: error: Invalid syntax
file:2: error: Yield expression cannot be used here

[case testImportDotModule]
import .x
[out]
file:1: error: Invalid syntax
file:1: error: Expected an import name

[case testImportDot]
import .
[out]
file:1: error: Invalid syntax
file:1: error: Expected an import name
file:1: error: Expected one or more symbol names after import

[case testInvalidFunctionName]
def while(): pass
[out]
file:1: error: Invalid syntax
file:1: error: Expected an identifier, but found a keyword `while` that cannot be used here

[case testInvalidEllipsis1]
...0
..._
...a
[out]
file:1: error: Invalid syntax
file:1: error: Simple statements must be separated by newlines or semicolons
file:2: error: Simple statements must be separated by newlines or semicolons
file:3: error: Simple statements must be separated by newlines or semicolons

[case testBlockStatementInSingleLineIf]
if 1: if 2: pass
[out]
file:1: error: Invalid syntax
file:1: error: Expected a simple statement

[case testBlockStatementInSingleLineIf2]
if 1: while 2: pass
[out]
file:1: error: Invalid syntax
file:1: error: Expected a simple statement

[case testBlockStatementInSingleLineIf3]
if 1: for x in y: pass
[out]
file:1: error: Invalid syntax
file:1: error: Expected a simple statement

[case testUnexpectedEllipsis]
a = a...
[out]
file:1: error: Invalid syntax
file:1: error: Simple statements must be separated by newlines or semicolons

[case testParseErrorBeforeUnicodeLiteral]
x u'y'
[out]
file:1: error: Invalid syntax
file:1: error: Simple statements must be separated by newlines or semicolons

[case testParseErrorInExtendedSlicing]
x[:,
[out]
file:1: error: '[' was never closed
file:1: error: Unexpected EOF while parsing

[case testParseErrorInExtendedSlicing2]
x[:,::
[out]
file:1: error: '[' was never closed
file:1: error: Unexpected EOF while parsing

[case testParseErrorInExtendedSlicing3]
x[:,:
[out]
file:1: error: '[' was never closed
file:1: error: Unexpected EOF while parsing

[case testInvalidEncoding]
# foo
Expand Down Expand Up @@ -407,17 +420,19 @@ file:0: error: Unknown encoding: uft8
2L
0x2L
[out]
file:1: error: Invalid decimal literal
file:1: error: Simple statements must be separated by newlines or semicolons
file:2: error: Simple statements must be separated by newlines or semicolons

[case testPython2LegacyInequalityInPython3]
1 <> 2
[out]
file:1: error: Invalid syntax
file:1: error: Expected an expression

[case testLambdaInListComprehensionInPython3]
([ 0 for x in 1, 2 if 3 ])
[out]
file:1: error: Invalid syntax
file:1: error: Expected `]`, found `,`
file:1: error: Expected `else`, found `]`

[case testTupleArgListInPython3]
def f(x, (y, z)): pass
Expand All @@ -427,12 +442,15 @@ file:1: error: Invalid syntax
[case testBackquoteInPython3]
`1 + 2`
[out]
file:1: error: Invalid syntax
file:1: error: Got unexpected token `
file:1: error: Expected a statement

[case testSmartQuotes]
foo = ‘bar’
[out]
file:1: error: Invalid character '‘' (U+2018)
file:1: error: Got unexpected token ‘
file:1: error: Got unexpected token ’
file:1: error: Expected a statement

[case testExceptCommaInPython3]
try:
Expand Down
Loading