1- from typing import List , Dict , Any , Optional
1+ import keyword
2+ from typing import List , Dict , Any
23
34from polygon .rest import models
45
5- StockSymbol = str
6- ConditionTypeMap = Dict [str , str ]
7- SymbolTypeMap = Dict [str , str ]
8- TickerSymbol = str
9-
106
117class Definition :
128 _swagger_name_to_python : Dict [str , str ]
@@ -23,8 +19,12 @@ def unmarshal_json(self, input_json):
2319 else :
2420 list_items = input_json
2521 self .__setattr__ (list_attribute_name , list_items )
22+ return self
2623 elif isinstance (input_json , dict ):
2724 self ._unmarshal_json_object (input_json )
25+ return self
26+ elif isinstance (input_json , float ) or isinstance (input_json , int ):
27+ return input_json
2828
2929 @staticmethod
3030 def _unmarshal_json_list (input_json , known_type ):
@@ -40,11 +40,13 @@ def _unmarshal_json_object(self, input_json):
4040 if key in self ._swagger_name_to_python :
4141 attribute_name = self ._swagger_name_to_python [key ]
4242 if not self ._attribute_is_primitive [attribute_name ]:
43- if attribute_name in models .name_to_class :
44- value = models .name_to_class [attribute_name ]()
45- value .unmarshal_json (input_json [key ])
43+ if attribute_name in self ._attributes_to_types :
44+ attribute_type = self ._attributes_to_types [attribute_name ]
45+ if attribute_type in models .name_to_class :
46+ model = models .name_to_class [attribute_type ]()
47+ value = model .unmarshal_json (input_json [key ])
4648 else :
47- attribute_name = key
49+ attribute_name = key + "_" if keyword . iskeyword ( key ) else ""
4850
4951 self .__setattr__ (attribute_name , value )
5052 return self
@@ -109,7 +111,7 @@ class LastQuote(Definition):
109111 "bidsize" : "bidsize" ,
110112 "bidexchange" : "bidexchange" ,
111113 "timestamp" : "timestamp" ,
112-
114+
113115 }
114116
115117 _attribute_is_primitive = {
@@ -3633,3 +3635,9 @@ class CryptoSnapshotGainersLosersApiResponse(Definition):
36333635 def __init__ (self ):
36343636 self .status : str
36353637 self .tickers : List [CryptoSnapshotTicker ]
3638+
3639+
3640+ StockSymbol = str
3641+ ConditionTypeMap = Dict [str , str ]
3642+ SymbolTypeMap = Dict [str , str ]
3643+ TickerSymbol = str
0 commit comments