Skip to content

Commit

Permalink
Changed error tests and message for 'invalid syntax -> Invalid syntax'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorysantosa committed May 12, 2023
1 parent 6080839 commit ce7f920
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 87 deletions.
2 changes: 1 addition & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def parse(
# lineno within the file.
e.lineno = None
message = e.msg
if feature_version > sys.version_info.minor and message.startswith("invalid syntax"):
if feature_version > sys.version_info.minor and message.startswith("Invalid syntax"):
python_version_str = f"{options.python_version[0]}.{options.python_version[1]}"
message += f"; you likely need to run mypy using Python {python_version_str} or newer"
errors.report(
Expand Down
2 changes: 1 addition & 1 deletion mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ def test_mypy_build(self) -> None:
output = run_stubtest(stub="+", runtime="", options=[])
assert remove_color_code(output) == (
"error: not checking stubs due to failed mypy compile:\n{}.pyi:1: "
"error: invalid syntax [syntax]\n".format(TEST_MODULE_NAME)
"error: Invalid syntax [syntax]\n".format(TEST_MODULE_NAME)
)

output = run_stubtest(stub="def f(): ...\ndef f(): ...", runtime="", options=[])
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ x in 1, # E: Unsupported right operand type for in ("int")
[case testTrailingCommaInIfParsing]
if x in 1, : pass
[out]
main:1: error: invalid syntax
main:1: error: Invalid syntax

[case testInitReturnTypeError]
class C:
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-columns.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
f()
1 +
[out]
main:2:5: error: invalid syntax
main:2:5: error: Invalid syntax

[case testColumnsNestedFunctions]
import typing
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ reveal_type(1) # N: Revealed type is "Literal[1]?"
[case testErrorCodeSyntaxError]
1 ''
[out]
main:1: error: invalid syntax [syntax]
main:1: error: Invalid syntax [syntax]
[out version==3.10.0]
main:1: error: invalid syntax. Perhaps you forgot a comma? [syntax]
main:1: error: Invalid syntax. Perhaps you forgot a comma? [syntax]

[case testErrorCodeSyntaxError2]
def f(): # E: Type signature has too many arguments [syntax]
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-expressions.test
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ None < None # E: Unsupported left operand type for < ("None")

[case testDictWithStarExpr]

b = {'z': 26, *a} # E: invalid syntax
b = {'z': 26, *a} # E: Invalid syntax
[builtins fixtures/dict.pyi]

[case testDictWithStarStarExpr]
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-fastparse.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[case testFastParseSyntaxError]

1 + # E: invalid syntax
1 + # E: Invalid syntax

[case testFastParseTypeCommentSyntaxError]

Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-ignore.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ from m import a # type: ignore
[file m.py]
+
[out]
tmp/m.py:1: error: invalid syntax
tmp/m.py:1: error: Invalid syntax

[case testIgnoreAppliesOnlyToMissing]
import a # type: ignore
Expand All @@ -59,7 +59,7 @@ from m import * # type: ignore
[file m.py]
+
[out]
tmp/m.py:1: error: invalid syntax
tmp/m.py:1: error: Invalid syntax

[case testIgnoreAssignmentTypeError]
x = 1
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-newsyntax.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ x: int = 5 # E: Variable annotation syntax is only supported in Python 3.6 and

[case testNewSyntaxSyntaxError]
# flags: --python-version 3.6
x: int: int # E: invalid syntax
x: int: int # E: Invalid syntax
[out]

[case testNewSyntaxBasics]
Expand Down Expand Up @@ -156,4 +156,4 @@ reveal_type(f'{1}') # N: Revealed type is "builtins.str"
# flags: --python-version 3.99
x *** x this is what future python looks like public static void main String[] args await goto exit
[out]
main:2: error: invalid syntax; you likely need to run mypy using Python 3.99 or newer
main:2: error: Invalid syntax; you likely need to run mypy using Python 3.99 or newer
6 changes: 3 additions & 3 deletions test-data/unit/check-parameter-specification.test
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def f2(c: Callable[P, R]) -> Callable[Concatenate[int, P], R]:
f2(lambda x: 42)(42, x=42)
[builtins fixtures/paramspec.pyi]
[out]
main:10: error: invalid syntax; you likely need to run mypy using Python 3.8 or newer
main:10: error: Invalid syntax; you likely need to run mypy using Python 3.8 or newer
[out version>=3.8]
main:17: error: Incompatible return value type (got "Callable[[Arg(int, 'x'), **P], R]", expected "Callable[[int, **P], R]")
main:17: note: This is likely because "result" has named arguments: "x". Consider marking them positional-only
Expand Down Expand Up @@ -621,7 +621,7 @@ def f2(c: Callable[P, R]) -> Callable[Concatenate[int, P], R]:
f2(lambda x: 42)(42, x=42)
[builtins fixtures/paramspec.pyi]
[out]
main:11: error: invalid syntax; you likely need to run mypy using Python 3.8 or newer
main:11: error: Invalid syntax; you likely need to run mypy using Python 3.8 or newer
[out version>=3.8]

[case testParamSpecConcatenateWithTypeVar]
Expand Down Expand Up @@ -662,7 +662,7 @@ reveal_type(abc)
bar(abc)
[builtins fixtures/paramspec.pyi]
[out]
main:13: error: invalid syntax; you likely need to run mypy using Python 3.8 or newer
main:13: error: Invalid syntax; you likely need to run mypy using Python 3.8 or newer
[out version>=3.8]
main:16: note: Revealed type is "__main__.Foo[[builtins.int, b: builtins.str]]"

Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-statements.test
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ def f() -> Iterator[List[int]]:

[case testYieldFromNotAppliedToNothing]
def h():
yield from # E: invalid syntax
yield from # E: Invalid syntax
[out]

[case testYieldFromAndYieldTogether]
Expand Down
8 changes: 4 additions & 4 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ some_file.py:11: error: Argument 1 to "some_interesting_method" of
[file some_file.py]
it_looks_like_we_started_typing_something_but_then. = did_not_notice(an_extra_dot)
[out]
some_file.py:1: error: invalid syntax [syntax]
some_file.py:1: error: Invalid syntax [syntax]
...ooks_like_we_started_typing_something_but_then. = did_not_notice(an_ex...
^
== Return code: 2
Expand Down Expand Up @@ -1299,15 +1299,15 @@ public static void main(String[] args)
[file pkg/y.py]
x: str = 0
[out]
pkg/x.py:1: error: invalid syntax
pkg/x.py:1: error: Invalid syntax
Found 1 error in 1 file (errors prevented further checking)
== Return code: 2
[out version>=3.10]
pkg/x.py:1: error: invalid syntax. Perhaps you forgot a comma?
pkg/x.py:1: error: Invalid syntax. Perhaps you forgot a comma?
Found 1 error in 1 file (errors prevented further checking)
== Return code: 2
[out version>=3.10.3]
pkg/x.py:1: error: invalid syntax
pkg/x.py:1: error: Invalid syntax
Found 1 error in 1 file (errors prevented further checking)
== Return code: 2

Expand Down
68 changes: 34 additions & 34 deletions test-data/unit/fine-grained-blockers.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def f(x: int) -> None: pass
def f() -> None: pass
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
main:2: error: Missing positional argument "x" in call to "f"
==
Expand All @@ -44,7 +44,7 @@ def f(x: int) -> None: pass
def f() -> None: pass
[out]
==
a.py:1: error: invalid syntax [syntax]
a.py:1: error: Invalid syntax [syntax]
def f(x: int) ->
^
==
Expand All @@ -54,7 +54,7 @@ main:3: error: Missing positional argument "x" in call to "f" [call-arg]
==
[out version>=3.8]
==
a.py:1: error: invalid syntax [syntax]
a.py:1: error: Invalid syntax [syntax]
def f(x: int) ->
^
==
Expand Down Expand Up @@ -87,9 +87,9 @@ def f(x: int
def f(x: int) -> None: pass
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
a.py:2: error: invalid syntax
a.py:2: error: Invalid syntax
==
main:2: error: Missing positional argument "x" in call to "f"
[out version>=3.10]
Expand Down Expand Up @@ -134,7 +134,7 @@ def f() -> None: pass
main:3: error: Too many arguments for "f"
main:5: error: Too many arguments for "f"
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
main:3: error: Too many arguments for "f"
main:5: error: Too many arguments for "f"
Expand Down Expand Up @@ -163,12 +163,12 @@ class C:
def f(self, x: int) -> None: pass
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
main:5: error: Missing positional argument "x" in call to "f" of "C"
[out version==3.10.0]
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
main:5: error: Missing positional argument "x" in call to "f" of "C"

Expand All @@ -183,14 +183,14 @@ def f() -> None: pass
main:1: error: Cannot find implementation or library stub for module named "a"
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
main:2: error: Too many arguments for "f"
[out version==3.10.0]
main:1: error: Cannot find implementation or library stub for module named "a"
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
main:2: error: Too many arguments for "f"

Expand Down Expand Up @@ -218,7 +218,7 @@ a.f()
def g() -> None: pass
[out]
==
b.py:1: error: invalid syntax
b.py:1: error: Invalid syntax
==

[case testModifyTwoFilesOneWithBlockingError2]
Expand All @@ -245,7 +245,7 @@ def f() -> None: pass
b.g()
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==

[case testBlockingErrorRemainsUnfixed]
Expand All @@ -264,16 +264,16 @@ import b
b.f()
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
a.py:2: error: Missing positional argument "x" in call to "f"
[out version==3.10.0]
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
a.py:2: error: Missing positional argument "x" in call to "f"

Expand Down Expand Up @@ -313,9 +313,9 @@ def g() -> None: pass
a.f(1)
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
a.py:3: error: Too many arguments for "g"
b.py:3: error: Too many arguments for "f"
Expand All @@ -335,14 +335,14 @@ x x
[delete a.py.3]
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
main:1: error: Cannot find implementation or library stub for module named "a"
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
b.py:1: error: Cannot find implementation or library stub for module named "a"
[out version==3.10.0]
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
main:1: error: Cannot find implementation or library stub for module named "a"
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Expand All @@ -363,14 +363,14 @@ x x
[delete a.py.3]
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
b.py:1: error: Cannot find implementation or library stub for module named "a"
b.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:1: error: Cannot find implementation or library stub for module named "a"
[out version==3.10.0]
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
b.py:1: error: Cannot find implementation or library stub for module named "a"
b.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Expand All @@ -392,17 +392,17 @@ a.f()
[builtins fixtures/module.pyi]
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
b.py:2: error: Module has no attribute "f"
b.py:3: error: "int" not callable
[out version==3.10.0]
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
b.py:2: error: Module has no attribute "f"
b.py:3: error: "int" not callable
Expand All @@ -418,12 +418,12 @@ import blocker
def f() -> None: pass
[out]
==
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: invalid syntax
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax
==
a.py:1: error: "int" not callable
[out version==3.10.0]
==
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: invalid syntax. Perhaps you forgot a comma?
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax. Perhaps you forgot a comma?
==
a.py:1: error: "int" not callable

Expand Down Expand Up @@ -495,16 +495,16 @@ import sys
[builtins fixtures/tuple.pyi]
[out]
==
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: invalid syntax
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax
==
a.py:2: error: "int" not callable
[out version==3.10.0]
==
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: invalid syntax. Perhaps you forgot a comma?
<ROOT>/test-data/unit/lib-stub/blocker.pyi:2: error: Invalid syntax. Perhaps you forgot a comma?
==
a.py:2: error: "int" not callable

Expand All @@ -521,12 +521,12 @@ x = 1
def f() -> int:
return 0
[out]
a.py:1: error: invalid syntax
a.py:1: error: Invalid syntax
==
b.py:2: error: Incompatible return value type (got "str", expected "int")
==
[out version==3.10.0]
a.py:1: error: invalid syntax. Perhaps you forgot a comma?
a.py:1: error: Invalid syntax. Perhaps you forgot a comma?
==
b.py:2: error: Incompatible return value type (got "str", expected "int")
==
Expand Down
Loading

0 comments on commit ce7f920

Please sign in to comment.