@@ -404,7 +404,7 @@ def __init__(
404404 def note (self , msg : str , line : int , column : int ) -> None :
405405 self .errors .report (line , column , msg , severity = "note" , code = codes .SYNTAX )
406406
407- def fail (self , msg : ErrorMessage , line : int , column : int , blocker : bool = True ) -> None :
407+ def fail (self , msg : ErrorMessage , line : int , column : int , blocker : bool ) -> None :
408408 if blocker or not self .options .ignore_errors :
409409 # Make sure self.errors reflects any type ignores that we have parsed
410410 self .errors .set_file_ignored_lines (
@@ -945,7 +945,12 @@ def do_func_def(
945945 ):
946946 if n .returns :
947947 # PEP 484 disallows both type annotations and type comments
948- self .fail (message_registry .DUPLICATE_TYPE_SIGNATURES , lineno , n .col_offset )
948+ self .fail (
949+ message_registry .DUPLICATE_TYPE_SIGNATURES ,
950+ lineno ,
951+ n .col_offset ,
952+ blocker = False ,
953+ )
949954 arg_types = [
950955 (
951956 a .type_annotation
@@ -957,7 +962,12 @@ def do_func_def(
957962 else :
958963 # PEP 484 disallows both type annotations and type comments
959964 if n .returns or any (a .type_annotation is not None for a in args ):
960- self .fail (message_registry .DUPLICATE_TYPE_SIGNATURES , lineno , n .col_offset )
965+ self .fail (
966+ message_registry .DUPLICATE_TYPE_SIGNATURES ,
967+ lineno ,
968+ n .col_offset ,
969+ blocker = False ,
970+ )
961971 translated_args : list [Type ] = TypeConverter (
962972 self .errors , line = lineno , override_column = n .col_offset
963973 ).translate_expr_list (func_type_ast .argtypes )
@@ -972,7 +982,7 @@ def do_func_def(
972982 except SyntaxError :
973983 stripped_type = n .type_comment .split ("#" , 2 )[0 ].strip ()
974984 err_msg = message_registry .TYPE_COMMENT_SYNTAX_ERROR_VALUE .format (stripped_type )
975- self .fail (err_msg , lineno , n .col_offset )
985+ self .fail (err_msg , lineno , n .col_offset , blocker = False )
976986 if n .type_comment and n .type_comment [0 ] not in ["(" , "#" ]:
977987 self .note (
978988 "Suggestion: wrap argument types in parentheses" , lineno , n .col_offset
@@ -994,7 +1004,12 @@ def do_func_def(
9941004 func_type = None
9951005 if any (arg_types ) or return_type :
9961006 if len (arg_types ) != 1 and any (isinstance (t , EllipsisType ) for t in arg_types ):
997- self .fail (message_registry .ELLIPSIS_WITH_OTHER_TYPEARGS , lineno , n .col_offset )
1007+ self .fail (
1008+ message_registry .ELLIPSIS_WITH_OTHER_TYPEARGS ,
1009+ lineno ,
1010+ n .col_offset ,
1011+ blocker = False ,
1012+ )
9981013 elif len (arg_types ) > len (arg_kinds ):
9991014 self .fail (
10001015 message_registry .TYPE_SIGNATURE_TOO_MANY_ARGS ,
@@ -1121,7 +1136,12 @@ def make_argument(
11211136 annotation = arg .annotation
11221137 type_comment = arg .type_comment
11231138 if annotation is not None and type_comment is not None :
1124- self .fail (message_registry .DUPLICATE_TYPE_SIGNATURES , arg .lineno , arg .col_offset )
1139+ self .fail (
1140+ message_registry .DUPLICATE_TYPE_SIGNATURES ,
1141+ arg .lineno ,
1142+ arg .col_offset ,
1143+ blocker = False ,
1144+ )
11251145 arg_type = None
11261146 if annotation is not None :
11271147 arg_type = TypeConverter (self .errors , line = arg .lineno ).visit (annotation )
@@ -1142,7 +1162,7 @@ def make_argument(
11421162 return argument
11431163
11441164 def fail_arg (self , msg : str , arg : ast3 .arg ) -> None :
1145- self .fail (ErrorMessage (msg ), arg .lineno , arg .col_offset )
1165+ self .fail (ErrorMessage (msg ), arg .lineno , arg .col_offset , blocker = True )
11461166
11471167 # ClassDef(identifier name,
11481168 # expr* bases,
@@ -1188,18 +1208,21 @@ def validate_type_param(self, type_param: ast_TypeVar) -> None:
11881208 message_registry .TYPE_VAR_YIELD_EXPRESSION_IN_BOUND ,
11891209 type_param .lineno ,
11901210 type_param .col_offset ,
1211+ blocker = True ,
11911212 )
11921213 if isinstance (incorrect_expr , ast3 .NamedExpr ):
11931214 self .fail (
11941215 message_registry .TYPE_VAR_NAMED_EXPRESSION_IN_BOUND ,
11951216 type_param .lineno ,
11961217 type_param .col_offset ,
1218+ blocker = True ,
11971219 )
11981220 if isinstance (incorrect_expr , ast3 .Await ):
11991221 self .fail (
12001222 message_registry .TYPE_VAR_AWAIT_EXPRESSION_IN_BOUND ,
12011223 type_param .lineno ,
12021224 type_param .col_offset ,
1225+ blocker = True ,
12031226 )
12041227
12051228 def translate_type_params (self , type_params : list [Any ]) -> list [TypeParam ]:
@@ -1814,11 +1837,26 @@ def validate_type_alias(self, n: ast_TypeAlias) -> None:
18141837 if incorrect_expr is None :
18151838 return
18161839 if isinstance (incorrect_expr , (ast3 .Yield , ast3 .YieldFrom )):
1817- self .fail (message_registry .TYPE_ALIAS_WITH_YIELD_EXPRESSION , n .lineno , n .col_offset )
1840+ self .fail (
1841+ message_registry .TYPE_ALIAS_WITH_YIELD_EXPRESSION ,
1842+ n .lineno ,
1843+ n .col_offset ,
1844+ blocker = True ,
1845+ )
18181846 if isinstance (incorrect_expr , ast3 .NamedExpr ):
1819- self .fail (message_registry .TYPE_ALIAS_WITH_NAMED_EXPRESSION , n .lineno , n .col_offset )
1847+ self .fail (
1848+ message_registry .TYPE_ALIAS_WITH_NAMED_EXPRESSION ,
1849+ n .lineno ,
1850+ n .col_offset ,
1851+ blocker = True ,
1852+ )
18201853 if isinstance (incorrect_expr , ast3 .Await ):
1821- self .fail (message_registry .TYPE_ALIAS_WITH_AWAIT_EXPRESSION , n .lineno , n .col_offset )
1854+ self .fail (
1855+ message_registry .TYPE_ALIAS_WITH_AWAIT_EXPRESSION ,
1856+ n .lineno ,
1857+ n .col_offset ,
1858+ blocker = True ,
1859+ )
18221860
18231861 # TypeAlias(identifier name, type_param* type_params, expr value)
18241862 def visit_TypeAlias (self , n : ast_TypeAlias ) -> TypeAliasStmt | AssignmentStmt :
0 commit comments