@@ -404,7 +404,7 @@ def __init__(
404
404
def note (self , msg : str , line : int , column : int ) -> None :
405
405
self .errors .report (line , column , msg , severity = "note" , code = codes .SYNTAX )
406
406
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 :
408
408
if blocker or not self .options .ignore_errors :
409
409
# Make sure self.errors reflects any type ignores that we have parsed
410
410
self .errors .set_file_ignored_lines (
@@ -945,7 +945,12 @@ def do_func_def(
945
945
):
946
946
if n .returns :
947
947
# 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
+ )
949
954
arg_types = [
950
955
(
951
956
a .type_annotation
@@ -957,7 +962,12 @@ def do_func_def(
957
962
else :
958
963
# PEP 484 disallows both type annotations and type comments
959
964
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
+ )
961
971
translated_args : list [Type ] = TypeConverter (
962
972
self .errors , line = lineno , override_column = n .col_offset
963
973
).translate_expr_list (func_type_ast .argtypes )
@@ -972,7 +982,7 @@ def do_func_def(
972
982
except SyntaxError :
973
983
stripped_type = n .type_comment .split ("#" , 2 )[0 ].strip ()
974
984
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 )
976
986
if n .type_comment and n .type_comment [0 ] not in ["(" , "#" ]:
977
987
self .note (
978
988
"Suggestion: wrap argument types in parentheses" , lineno , n .col_offset
@@ -994,7 +1004,12 @@ def do_func_def(
994
1004
func_type = None
995
1005
if any (arg_types ) or return_type :
996
1006
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
+ )
998
1013
elif len (arg_types ) > len (arg_kinds ):
999
1014
self .fail (
1000
1015
message_registry .TYPE_SIGNATURE_TOO_MANY_ARGS ,
@@ -1121,7 +1136,12 @@ def make_argument(
1121
1136
annotation = arg .annotation
1122
1137
type_comment = arg .type_comment
1123
1138
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
+ )
1125
1145
arg_type = None
1126
1146
if annotation is not None :
1127
1147
arg_type = TypeConverter (self .errors , line = arg .lineno ).visit (annotation )
@@ -1142,7 +1162,7 @@ def make_argument(
1142
1162
return argument
1143
1163
1144
1164
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 )
1146
1166
1147
1167
# ClassDef(identifier name,
1148
1168
# expr* bases,
@@ -1188,18 +1208,21 @@ def validate_type_param(self, type_param: ast_TypeVar) -> None:
1188
1208
message_registry .TYPE_VAR_YIELD_EXPRESSION_IN_BOUND ,
1189
1209
type_param .lineno ,
1190
1210
type_param .col_offset ,
1211
+ blocker = True ,
1191
1212
)
1192
1213
if isinstance (incorrect_expr , ast3 .NamedExpr ):
1193
1214
self .fail (
1194
1215
message_registry .TYPE_VAR_NAMED_EXPRESSION_IN_BOUND ,
1195
1216
type_param .lineno ,
1196
1217
type_param .col_offset ,
1218
+ blocker = True ,
1197
1219
)
1198
1220
if isinstance (incorrect_expr , ast3 .Await ):
1199
1221
self .fail (
1200
1222
message_registry .TYPE_VAR_AWAIT_EXPRESSION_IN_BOUND ,
1201
1223
type_param .lineno ,
1202
1224
type_param .col_offset ,
1225
+ blocker = True ,
1203
1226
)
1204
1227
1205
1228
def translate_type_params (self , type_params : list [Any ]) -> list [TypeParam ]:
@@ -1814,11 +1837,26 @@ def validate_type_alias(self, n: ast_TypeAlias) -> None:
1814
1837
if incorrect_expr is None :
1815
1838
return
1816
1839
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
+ )
1818
1846
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
+ )
1820
1853
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
+ )
1822
1860
1823
1861
# TypeAlias(identifier name, type_param* type_params, expr value)
1824
1862
def visit_TypeAlias (self , n : ast_TypeAlias ) -> TypeAliasStmt | AssignmentStmt :
0 commit comments