Skip to content

Commit eb302cf

Browse files
committed
Raise on all parse_error calls
1 parent e0d6bf2 commit eb302cf

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mypy/parse.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def parse_arg_list(self, allow_signature: bool = True,
630630
elif self.current_str() in ['*', '**']:
631631
if bare_asterisk_before == len(args):
632632
# named arguments must follow bare *
633-
self.parse_error()
633+
raise self.parse_error()
634634

635635
arg = self.parse_asterisk_arg(
636636
allow_signature,
@@ -991,7 +991,7 @@ def parse_return_stmt(self) -> ReturnStmt:
991991
expr = None
992992
current = self.current()
993993
if current.string == 'yield':
994-
self.parse_error()
994+
raise self.parse_error()
995995
if not isinstance(current, Break):
996996
expr = self.parse_expression()
997997
node = ReturnStmt(expr)
@@ -1247,10 +1247,10 @@ def parse_print_stmt(self) -> PrintStmt:
12471247
if self.current_str() == ',':
12481248
self.skip()
12491249
if isinstance(self.current(), Break):
1250-
self.parse_error()
1250+
raise self.parse_error()
12511251
else:
12521252
if not isinstance(self.current(), Break):
1253-
self.parse_error()
1253+
raise self.parse_error()
12541254
comma = False
12551255
while not isinstance(self.current(), Break):
12561256
args.append(self.parse_expression(precedence[',']))
@@ -1325,7 +1325,7 @@ def parse_expression(self, prec: int = 0, star_expr_allowed: bool = False) -> Ex
13251325
expr = self.parse_ellipsis()
13261326
else:
13271327
# Invalid expression.
1328-
self.parse_error()
1328+
raise self.parse_error()
13291329

13301330
# Set the line of the expression node, if not specified. This
13311331
# simplifies recording the line number as not every node type needs to
@@ -1500,7 +1500,7 @@ def parse_dict_or_set_expr(self) -> Union[SetComprehension, SetExpr,
15001500
elif self.current_str() == 'for' and items == []:
15011501
return self.parse_set_comprehension(key)
15021502
elif self.current_str() != ':':
1503-
self.parse_error()
1503+
raise self.parse_error()
15041504
colon = self.expect(':')
15051505
value = self.parse_expression(precedence['<for>'])
15061506
if self.current_str() == 'for' and items == []:
@@ -1670,7 +1670,7 @@ def parse_arg_expr(self) -> Tuple[List[Expression], List[int], List[str]]:
16701670
kinds.append(nodes.ARG_POS)
16711671
names.append(None)
16721672
else:
1673-
self.parse_error()
1673+
raise self.parse_error()
16741674
args.append(self.parse_expression(precedence[',']))
16751675
if self.current_str() != ',':
16761676
break
@@ -1738,7 +1738,7 @@ def parse_bin_op_expr(self, left: Expression, prec: int) -> OpExpr:
17381738
op_str = op.string
17391739
if op_str == '~':
17401740
self.ind -= 1
1741-
self.parse_error()
1741+
raise self.parse_error()
17421742
right = self.parse_expression(prec)
17431743
node = OpExpr(op_str, left, right)
17441744
return node
@@ -1755,7 +1755,7 @@ def parse_comparison_expr(self, left: Expression, prec: int) -> ComparisonExpr:
17551755
op_str = 'not in'
17561756
self.skip()
17571757
else:
1758-
self.parse_error()
1758+
raise self.parse_error()
17591759
elif op_str == 'is' and self.current_str() == 'not':
17601760
op_str = 'is not'
17611761
self.skip()

0 commit comments

Comments
 (0)