@@ -381,7 +381,7 @@ def __init__(
381381 def note (self , msg : str , line : int , column : int ) -> None :
382382 self .errors .report (line , column , msg , severity = "note" , code = codes .SYNTAX )
383383
384- def fail (self , msg : ErrorMessage , line : int , column : int , blocker : bool = True ) -> None :
384+ def fail (self , msg : ErrorMessage , line : int , column : int , blocker : bool ) -> None :
385385 if blocker or not self .options .ignore_errors :
386386 # Make sure self.errors reflects any type ignores that we have parsed
387387 self .errors .set_file_ignored_lines (
@@ -921,7 +921,12 @@ def do_func_def(
921921 ):
922922 if n .returns :
923923 # PEP 484 disallows both type annotations and type comments
924- self .fail (message_registry .DUPLICATE_TYPE_SIGNATURES , lineno , n .col_offset )
924+ self .fail (
925+ message_registry .DUPLICATE_TYPE_SIGNATURES ,
926+ lineno ,
927+ n .col_offset ,
928+ blocker = False ,
929+ )
925930 arg_types = [
926931 (
927932 a .type_annotation
@@ -933,7 +938,12 @@ def do_func_def(
933938 else :
934939 # PEP 484 disallows both type annotations and type comments
935940 if n .returns or any (a .type_annotation is not None for a in args ):
936- self .fail (message_registry .DUPLICATE_TYPE_SIGNATURES , lineno , n .col_offset )
941+ self .fail (
942+ message_registry .DUPLICATE_TYPE_SIGNATURES ,
943+ lineno ,
944+ n .col_offset ,
945+ blocker = False ,
946+ )
937947 translated_args : list [Type ] = TypeConverter (
938948 self .errors , line = lineno , override_column = n .col_offset
939949 ).translate_expr_list (func_type_ast .argtypes )
@@ -948,7 +958,7 @@ def do_func_def(
948958 except SyntaxError :
949959 stripped_type = n .type_comment .split ("#" , 2 )[0 ].strip ()
950960 err_msg = message_registry .TYPE_COMMENT_SYNTAX_ERROR_VALUE .format (stripped_type )
951- self .fail (err_msg , lineno , n .col_offset )
961+ self .fail (err_msg , lineno , n .col_offset , blocker = False )
952962 if n .type_comment and n .type_comment [0 ] not in ["(" , "#" ]:
953963 self .note (
954964 "Suggestion: wrap argument types in parentheses" , lineno , n .col_offset
@@ -970,7 +980,12 @@ def do_func_def(
970980 func_type = None
971981 if any (arg_types ) or return_type :
972982 if len (arg_types ) != 1 and any (isinstance (t , EllipsisType ) for t in arg_types ):
973- self .fail (message_registry .ELLIPSIS_WITH_OTHER_TYPEARGS , lineno , n .col_offset )
983+ self .fail (
984+ message_registry .ELLIPSIS_WITH_OTHER_TYPEARGS ,
985+ lineno ,
986+ n .col_offset ,
987+ blocker = False ,
988+ )
974989 elif len (arg_types ) > len (arg_kinds ):
975990 self .fail (
976991 message_registry .TYPE_SIGNATURE_TOO_MANY_ARGS ,
@@ -1097,7 +1112,12 @@ def make_argument(
10971112 annotation = arg .annotation
10981113 type_comment = arg .type_comment
10991114 if annotation is not None and type_comment is not None :
1100- self .fail (message_registry .DUPLICATE_TYPE_SIGNATURES , arg .lineno , arg .col_offset )
1115+ self .fail (
1116+ message_registry .DUPLICATE_TYPE_SIGNATURES ,
1117+ arg .lineno ,
1118+ arg .col_offset ,
1119+ blocker = False ,
1120+ )
11011121 arg_type = None
11021122 if annotation is not None :
11031123 arg_type = TypeConverter (self .errors , line = arg .lineno ).visit (annotation )
@@ -1118,7 +1138,7 @@ def make_argument(
11181138 return argument
11191139
11201140 def fail_arg (self , msg : str , arg : ast3 .arg ) -> None :
1121- self .fail (ErrorMessage (msg ), arg .lineno , arg .col_offset )
1141+ self .fail (ErrorMessage (msg ), arg .lineno , arg .col_offset , blocker = True )
11221142
11231143 # ClassDef(identifier name,
11241144 # expr* bases,
@@ -1164,18 +1184,21 @@ def validate_type_param(self, type_param: ast_TypeVar) -> None:
11641184 message_registry .TYPE_VAR_YIELD_EXPRESSION_IN_BOUND ,
11651185 type_param .lineno ,
11661186 type_param .col_offset ,
1187+ blocker = True ,
11671188 )
11681189 if isinstance (incorrect_expr , ast3 .NamedExpr ):
11691190 self .fail (
11701191 message_registry .TYPE_VAR_NAMED_EXPRESSION_IN_BOUND ,
11711192 type_param .lineno ,
11721193 type_param .col_offset ,
1194+ blocker = True ,
11731195 )
11741196 if isinstance (incorrect_expr , ast3 .Await ):
11751197 self .fail (
11761198 message_registry .TYPE_VAR_AWAIT_EXPRESSION_IN_BOUND ,
11771199 type_param .lineno ,
11781200 type_param .col_offset ,
1201+ blocker = True ,
11791202 )
11801203
11811204 def translate_type_params (self , type_params : list [Any ]) -> list [TypeParam ]:
@@ -1790,11 +1813,26 @@ def validate_type_alias(self, n: ast_TypeAlias) -> None:
17901813 if incorrect_expr is None :
17911814 return
17921815 if isinstance (incorrect_expr , (ast3 .Yield , ast3 .YieldFrom )):
1793- self .fail (message_registry .TYPE_ALIAS_WITH_YIELD_EXPRESSION , n .lineno , n .col_offset )
1816+ self .fail (
1817+ message_registry .TYPE_ALIAS_WITH_YIELD_EXPRESSION ,
1818+ n .lineno ,
1819+ n .col_offset ,
1820+ blocker = True ,
1821+ )
17941822 if isinstance (incorrect_expr , ast3 .NamedExpr ):
1795- self .fail (message_registry .TYPE_ALIAS_WITH_NAMED_EXPRESSION , n .lineno , n .col_offset )
1823+ self .fail (
1824+ message_registry .TYPE_ALIAS_WITH_NAMED_EXPRESSION ,
1825+ n .lineno ,
1826+ n .col_offset ,
1827+ blocker = True ,
1828+ )
17961829 if isinstance (incorrect_expr , ast3 .Await ):
1797- self .fail (message_registry .TYPE_ALIAS_WITH_AWAIT_EXPRESSION , n .lineno , n .col_offset )
1830+ self .fail (
1831+ message_registry .TYPE_ALIAS_WITH_AWAIT_EXPRESSION ,
1832+ n .lineno ,
1833+ n .col_offset ,
1834+ blocker = True ,
1835+ )
17981836
17991837 # TypeAlias(identifier name, type_param* type_params, expr value)
18001838 def visit_TypeAlias (self , n : ast_TypeAlias ) -> TypeAliasStmt | AssignmentStmt :
0 commit comments