File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -47,8 +47,13 @@ def record_getitem(ctx: mypy.plugin.MethodContext) \
4747 name = value
4848
4949 if name is None :
50- ctx .api .fail ('Unexpected key "{}" for record "{}'
51- .format (value , ctx .type .type .name ),
50+ is_int = isinstance (value , int )
51+ formatted_key = value if is_int else \
52+ "'{}'" .format (value )
53+ ctx .api .fail ('Record "{}" has no {} {}'
54+ .format (ctx .type .type .name ,
55+ 'index' if is_int else 'key' ,
56+ formatted_key ),
5257 ctx .context )
5358 else :
5459 node = ctx .type .type .get (name )
@@ -79,8 +84,8 @@ def record_get(ctx: mypy.plugin.MethodContext) \
7984 name = value
8085
8186 if name is None :
82- ctx .api .fail ('Unexpected key "{}" for record "{} '
83- .format (value , ctx .type .type .name ),
87+ ctx .api .fail ('Record "{}" has no key \' {} \' '
88+ .format (ctx .type .type .name , value ),
8489 ctx .context )
8590 else :
8691 node = ctx .type .type .get (name )
You can’t perform that action at this time.
0 commit comments