Skip to content

syntax error messages capitalization #19114

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

Merged
merged 8 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ def parse(
errors.report(
e.lineno if e.lineno is not None else -1,
e.offset,
message,
re.sub(
r"^(\s*\w)", lambda m: m.group(1).upper(), message
), # Standardizing error message
blocker=True,
code=codes.SYNTAX,
)
Expand Down
2 changes: 1 addition & 1 deletion mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@ def test_mypy_build(self) -> None:
output = run_stubtest(stub="+", runtime="", options=[])
assert 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 @@ -289,7 +289,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 @@ -1861,7 +1861,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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -158,7 +158,7 @@ def f(a, # type: A

[case testFastParsePerArgumentAnnotationsWithAnnotatedBareStar]

def f(*, # type: int # E: bare * has associated type comment
def f(*, # type: int # E: Bare * has associated type comment
x # type: str
):
# type: (...) -> int
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
@@ -1,5 +1,5 @@
[case testNewSyntaxSyntaxError]
x: int: int # E: invalid syntax
x: int: int # E: Invalid syntax
[out]

[case testNewSyntaxBasics]
Expand Down Expand Up @@ -126,4 +126,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
2 changes: 1 addition & 1 deletion test-data/unit/check-statements.test
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,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 @@ -896,7 +896,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 @@ -1035,15 +1035,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
Loading