File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 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) \
8484 name = value
8585
8686 if name is None :
87+ if default_arg is not None :
88+ return default_arg
89+
8790 ctx .api .fail ('Record "{}" has no key \' {}\' '
8891 .format (ctx .type .type .name , value ),
8992 ctx .context )
9093 else :
9194 node = ctx .type .type .get (name )
9295
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
10298
10399 return ctx .default_return_type
Original file line number Diff line number Diff line change @@ -210,9 +210,9 @@ _T = TypeVar('_T')
210210
211211class Record :
212212 @overload
213- def get (self , key : Any ) -> Optional [Any ]: ...
213+ def get (self , key : str ) -> Optional [Any ]: ...
214214 @overload
215- def get (self , key : Any , default : _T ) -> Union [Any , _T ]: ...
215+ def get (self , key : str , default : _T ) -> Union [Any , _T ]: ...
216216 def items (self ) -> Iterator [Tuple [str , Any ]]: ...
217217 def keys (self ) -> Iterator [str ]: ...
218218 def values (self ) -> Iterator [Any ]: ...
You can’t perform that action at this time.
0 commit comments