@@ -15,27 +15,17 @@ def mark_record(ctx: mypy.plugin.ClassDefContext) -> None:
1515 utils .mark_record (ctx .cls .info )
1616
1717
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-
2818def record_attribute (ctx : mypy .plugin .AttributeContext ) \
2919 -> mypy .types .Type :
3020 if isinstance (ctx .type , mypy .types .Instance ) and \
3121 utils .is_record (ctx .type .type ):
3222 assert isinstance (ctx .context , mypy .nodes .MemberExpr )
33- symbol = ctx .type .type .get (ctx .context .name )
3423
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 )
3929
4030 return ctx .default_attr_type
4131
0 commit comments