File tree 2 files changed +7
-11
lines changed
2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -84,20 +84,16 @@ def record_get(ctx: mypy.plugin.MethodContext) \
84
84
name = value
85
85
86
86
if name is None :
87
+ if default_arg is not None :
88
+ return default_arg
89
+
87
90
ctx .api .fail ('Record "{}" has no key \' {}\' '
88
91
.format (ctx .type .type .name , value ),
89
92
ctx .context )
90
93
else :
91
94
node = ctx .type .type .get (name )
92
95
93
- assert node is not None
94
-
95
- if node .type is not None :
96
- if default_arg is not None :
97
- return mypy .types .UnionType ([node .type , default_arg ],
98
- ctx .context .line ,
99
- ctx .context .column )
100
- else :
101
- return node .type
96
+ if node is not None and node .type is not None :
97
+ return node .type
102
98
103
99
return ctx .default_return_type
Original file line number Diff line number Diff line change @@ -210,9 +210,9 @@ _T = TypeVar('_T')
210
210
211
211
class Record :
212
212
@overload
213
- def get (self , key : Any ) -> Optional [Any ]: ...
213
+ def get (self , key : str ) -> Optional [Any ]: ...
214
214
@overload
215
- def get (self , key : Any , default : _T ) -> Union [Any , _T ]: ...
215
+ def get (self , key : str , default : _T ) -> Union [Any , _T ]: ...
216
216
def items (self ) -> Iterator [Tuple [str , Any ]]: ...
217
217
def keys (self ) -> Iterator [str ]: ...
218
218
def values (self ) -> Iterator [Any ]: ...
You can’t perform that action at this time.
0 commit comments