File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -46,20 +46,20 @@ def is_annotated(annotation: ast.expr | None) -> TypeGuard[ast.expr]:
46
46
47
47
def visit_arg (self , node : ast .arg ) -> None :
48
48
if self .is_annotated (node .annotation ):
49
- annotation = node .annotation
50
- if (
51
- hasattr (annotation , "value" )
52
- and annotation .value .id in self ._concrete_type_hint_error_codes
53
- ):
54
- self .errors .append (
55
- (
56
- node .lineno ,
57
- node .col_offset ,
58
- self ._concrete_type_hint_error_codes [
59
- annotation .value .id
60
- ],
49
+ # node.annotations is ast.Name, ast.Subscript or ast.Attribute
50
+ if isinstance (node .annotation , ast .Subscript ):
51
+ value_node = node .annotation .value
52
+ assert isinstance (value_node , ast .Name )
53
+ if value_node .id in self ._concrete_type_hint_error_codes :
54
+ self .errors .append (
55
+ (
56
+ node .lineno ,
57
+ node .col_offset ,
58
+ self ._concrete_type_hint_error_codes [
59
+ value_node .id
60
+ ],
61
+ )
61
62
)
62
- )
63
63
self .generic_visit (node )
64
64
65
65
You can’t perform that action at this time.
0 commit comments