@@ -15,27 +15,17 @@ def mark_record(ctx: mypy.plugin.ClassDefContext) -> None:
15
15
utils .mark_record (ctx .cls .info )
16
16
17
17
18
- def record_final_attributes (ctx : mypy .plugin .ClassDefContext ) -> None :
19
- if utils .is_record (ctx .cls .info ):
20
- for name , value in ctx .cls .info .names .items ():
21
- # set all properties as Final so they can't be set
22
- if isinstance (value .node , mypy .nodes .Var ):
23
- value .node .is_final = True
24
- value .node .final_set_in_init = True
25
- value .node .final_unset_in_class = True
26
-
27
-
28
18
def record_attribute (ctx : mypy .plugin .AttributeContext ) \
29
19
-> mypy .types .Type :
30
20
if isinstance (ctx .type , mypy .types .Instance ) and \
31
21
utils .is_record (ctx .type .type ):
32
22
assert isinstance (ctx .context , mypy .nodes .MemberExpr )
33
- symbol = ctx .type .type .get (ctx .context .name )
34
23
35
- if symbol is None :
36
- ctx .api .fail ('"{}" has no attribute "{}"'
37
- .format (ctx .type .type .name , ctx .context .name ),
38
- ctx .context )
24
+ # raise an error when users try to access the keys defined
25
+ # using attribute notation
26
+ ctx .api .fail ('"{}" has no attribute "{}"'
27
+ .format (ctx .type .type .name , ctx .context .name ),
28
+ ctx .context )
39
29
40
30
return ctx .default_attr_type
41
31
0 commit comments