Skip to content

Commit

Permalink
Revert "Fixed the 'syntax error in type comment -> Syntax error in ty…
Browse files Browse the repository at this point in the history
…pe comment' for test cases and the error print in mypy/message_registry.py"

This reverts commit 6080839.
  • Loading branch information
gregorysantosa committed May 12, 2023
1 parent ce7f920 commit f468fbb
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion mypy/message_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def with_additional_msg(self, info: str) -> ErrorMessage:
)
INVALID_TYPE_IGNORE: Final = ErrorMessage('Invalid "type: ignore" comment', codes.SYNTAX)
TYPE_COMMENT_SYNTAX_ERROR_VALUE: Final = ErrorMessage(
'Syntax error in type comment "{}"', codes.SYNTAX
'syntax error in type comment "{}"', codes.SYNTAX
)
ELLIPSIS_WITH_OTHER_TYPEARGS: Final = ErrorMessage(
"Ellipses cannot accompany other argument types in function type signature", codes.SYNTAX
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 @@ -328,7 +328,7 @@ if int():
# TODO: It would be better to point to the type comment
xyz = 0 # type: blurbnard blarb
[out]
main:3:5: error: Syntax error in type comment "blurbnard blarb"
main:3:5: error: syntax error in type comment "blurbnard blarb"

[case testColumnProperty]
class A:
Expand Down
6 changes: 3 additions & 3 deletions test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def f(): # E: Type signature has too many arguments [syntax]
# type: (int) -> None
1

x = 0 # type: x y # E: Syntax error in type comment "x y" [syntax]
x = 0 # type: x y # E: syntax error in type comment "x y" [syntax]

[case testErrorCodeSyntaxError3]
# This is a bit inconsistent -- syntax error would be more logical?
Expand Down Expand Up @@ -720,8 +720,8 @@ main:2: error: Name "y" is not defined [name-defined]
x = y # type: int # type: ignored[foo]
x = y # type: int # type: ignored [foo]
[out]
main:1: error: Syntax error in type comment "int" [syntax]
main:2: error: Syntax error in type comment "int" [syntax]
main:1: error: syntax error in type comment "int" [syntax]
main:2: error: syntax error in type comment "int" [syntax]

[case testErrorCode__exit__Return]
class InvalidReturn:
Expand Down
6 changes: 3 additions & 3 deletions test-data/unit/check-fastparse.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[case testFastParseTypeCommentSyntaxError]

x = None # type: a : b # E: Syntax error in type comment "a : b"
x = None # type: a : b # E: syntax error in type comment "a : b"

[case testFastParseInvalidTypeComment]

Expand All @@ -14,13 +14,13 @@ x = None # type: a + b # E: Invalid type comment or annotation
-- This happens in both parsers.
[case testFastParseFunctionAnnotationSyntaxError]

def f(): # E: Syntax error in type comment "None -> None" # N: Suggestion: wrap argument types in parentheses
def f(): # E: syntax error in type comment "None -> None" # N: Suggestion: wrap argument types in parentheses
# type: None -> None
pass

[case testFastParseFunctionAnnotationSyntaxErrorSpaces]

def f(): # E: Syntax error in type comment "None -> None" # N: Suggestion: wrap argument types in parentheses
def f(): # E: syntax error in type comment "None -> None" # N: Suggestion: wrap argument types in parentheses
# type: None -> None
pass

Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-literal.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ reveal_type(g2) # N: Revealed type is "def (x: Literal['A B'])"

[case testLiteralInvalidTypeComment]
from typing_extensions import Literal
def f(x): # E: Syntax error in type comment "(A[) -> None"
def f(x): # E: syntax error in type comment "(A[) -> None"
# type: (A[) -> None
pass

Expand Down
40 changes: 20 additions & 20 deletions test-data/unit/parse-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -113,116 +113,116 @@ file:1: error: Invalid syntax
0
x = 0 # type: A A
[out]
file:2: error: Syntax error in type comment "A A"
file:2: error: syntax error in type comment "A A"

[case testInvalidTypeComment2]
0
x = 0 # type: A[
[out]
file:2: error: Syntax error in type comment "A["
file:2: error: syntax error in type comment "A["

[case testInvalidTypeComment3]
0
x = 0 # type:
[out]
file:2: error: Syntax error in type comment ""
file:2: error: syntax error in type comment ""

[case testInvalidTypeComment4]
0
x = 0 # type: *
[out]
file:2: error: Syntax error in type comment "*"
file:2: error: syntax error in type comment "*"

[case testInvalidTypeComment5]
0
x = 0 # type:# some comment
[out]
file:2: error: Syntax error in type comment ""
file:2: error: syntax error in type comment ""

[case testInvalidTypeComment6]
0
x = 0 # type: *# comment #6
[out]
file:2: error: Syntax error in type comment "*"
file:2: error: syntax error in type comment "*"

[case testInvalidTypeComment7]
0
x = 0 # type: A B #comment #7
[out]
file:2: error: Syntax error in type comment "A B"
file:2: error: syntax error in type comment "A B"

[case testInvalidSignatureInComment1]
def f(): # type: x
pass
[out]
file:1: error: Syntax error in type comment "x"
file:1: error: syntax error in type comment "x"
file:1: note: Suggestion: wrap argument types in parentheses

[case testInvalidSignatureInComment2]
def f(): # type:
pass
[out]
file:1: error: Syntax error in type comment ""
file:1: error: syntax error in type comment ""

[case testInvalidSignatureInComment3]
def f(): # type: (
pass
[out]
file:1: error: Syntax error in type comment "("
file:1: error: syntax error in type comment "("

[case testInvalidSignatureInComment4]
def f(): # type: (.
pass
[out]
file:1: error: Syntax error in type comment "(."
file:1: error: syntax error in type comment "(."

[case testInvalidSignatureInComment5]
def f(): # type: (x
pass
[out]
file:1: error: Syntax error in type comment "(x"
file:1: error: syntax error in type comment "(x"

[case testInvalidSignatureInComment6]
def f(): # type: (x)
pass
[out]
file:1: error: Syntax error in type comment "(x)"
file:1: error: syntax error in type comment "(x)"

[case testInvalidSignatureInComment7]
def f(): # type: (x) -
pass
[out]
file:1: error: Syntax error in type comment "(x) -"
file:1: error: syntax error in type comment "(x) -"

[case testInvalidSignatureInComment8]
def f(): # type: (x) ->
pass
[out]
file:1: error: Syntax error in type comment "(x) ->"
file:1: error: syntax error in type comment "(x) ->"

[case testInvalidSignatureInComment9]
def f(): # type: (x) -> .
pass
[out]
file:1: error: Syntax error in type comment "(x) -> ."
file:1: error: syntax error in type comment "(x) -> ."

[case testInvalidSignatureInComment10]
def f(): # type: (x) -> x x
pass
[out]
file:1: error: Syntax error in type comment "(x) -> x x"
file:1: error: syntax error in type comment "(x) -> x x"

[case testInvalidSignatureInComment11]
def f(): # type: # abc comment
pass
[out]
file:1: error: Syntax error in type comment ""
file:1: error: syntax error in type comment ""

[case testInvalidSignatureInComment12]
def f(): # type: (x) -> x x # comment #2
pass
[out]
file:1: error: Syntax error in type comment "(x) -> x x"
file:1: error: syntax error in type comment "(x) -> x x"


[case testDuplicateSignatures1]
Expand Down Expand Up @@ -269,7 +269,7 @@ def g(*x, **y): # type: (*X, *Y) -> Z
pass
[out]
file:1: error: Inconsistent use of "*" in function signature
file:3: error: Syntax error in type comment
file:3: error: syntax error in type comment
file:3: error: Inconsistent use of "*" in function signature
file:3: error: Inconsistent use of "**" in function signature

Expand Down

0 comments on commit f468fbb

Please sign in to comment.