Skip to content

Commit edebe02

Browse files
authored
1 parent 35f402c commit edebe02

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

mypy/fastparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def parse_type_string(
318318
string expression "blah" using this function.
319319
"""
320320
try:
321-
_, node = parse_type_comment(expr_string.strip(), line=line, column=column, errors=None)
321+
_, node = parse_type_comment(f"({expr_string})", line=line, column=column, errors=None)
322322
if isinstance(node, UnboundType) and node.original_str_expr is None:
323323
node.original_str_expr = expr_string
324324
node.original_str_fallback = expr_fallback_name

test-data/unit/check-basic.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,19 @@ s2: str = 42 # E: Incompatible types in assignment (expression has type "int",
502502
s3: str = 42 # E: Incompatible types in assignment (expression has type "int", variable has type "str")
503503
[file c.py]
504504
s3: str = 'foo'
505+
506+
[case testMultilineQuotedAnnotation]
507+
x: """
508+
509+
int |
510+
str
511+
512+
"""
513+
reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str]"
514+
515+
y: """(
516+
int |
517+
str
518+
)
519+
"""
520+
reveal_type(y) # N: Revealed type is "Union[builtins.int, builtins.str]"

0 commit comments

Comments
 (0)