@@ -257,13 +257,16 @@ def reverse_map(self):
257257 def nodes (self ):
258258 return [k .name for k in self ._cls .__attrs_attrs__ ]
259259
260- def _cast_all_maps (self , changed_vars : Set ):
261- for val in changed_vars :
262- self ._fields [val ] = self .var_resolver .attempt_cast (
263- self ._fields [val ], getattr (self ._cls .__attrs_attrs__ , val ).type , val
264- )
260+ def resolve (self ) -> Tuple [Dict , Set ]:
261+ """Resolves variable references by searching thorough the current spock_space
262+
263+ Args:
265264
266- def resolve (self ) -> Dict :
265+ Returns:
266+ field dictionary containing the resolved values and a set containing all
267+ changed variables to delay casting post resolution
268+
269+ """
267270 # Iterate in topo order
268271 for k in self .topological_order :
269272 # get the self dependent values and swap within the fields dict
@@ -275,9 +278,8 @@ def resolve(self) -> Dict:
275278 name = v ,
276279 )
277280 self ._fields [v ] = typed_val
278- # Get a set of all changed variables and attempt to cast them
279- self ._cast_all_maps (set (self ._ref_map .keys ()))
280- return self ._fields
281+ # Get a set of all changed variables
282+ return self ._fields , set (self ._ref_map .keys ())
281283
282284 def _build (self ) -> Tuple [Dict , Dict ]:
283285 """Builds a dictionary of nodes and their edges (essentially builds the DAG)
@@ -363,35 +365,20 @@ def ref_2_resolve(self) -> Set:
363365 """Returns the values that need to be resolved"""
364366 return set (self .ref_map .keys ())
365367
366- def _cast_all_maps (self , cls_name : str , changed_vars : Set ) -> None :
367- """Casts all the resolved references to the requested type
368-
369- Args:
370- cls_name: name of the underlying class
371- changed_vars: set of resolved variables that need to be cast
372-
373- Returns:
374-
375- """
376- for val in changed_vars :
377- self .cls_map [cls_name ][val ] = self .var_resolver .attempt_cast (
378- self .cls_map [cls_name ][val ],
379- getattr (self .node_map [cls_name ].__attrs_attrs__ , val ).type ,
380- val ,
381- )
382-
383- def resolve (self , spock_cls : str , spock_space : Dict ) -> Dict :
368+ def resolve (self , spock_cls : str , spock_space : Dict ) -> Tuple [Dict , Set ]:
384369 """Resolves variable references by searching thorough the current spock_space
385370
386371 Args:
387372 spock_cls: name of the spock class
388373 spock_space: current spock_space to look for the underlying value
389374
390375 Returns:
391- field dictionary containing the resolved values
376+ field dictionary containing the resolved values and a set containing all
377+ changed variables to delay casting post resolution
392378
393379 """
394380 # First we check for any needed variable resolution
381+ changed_vars = set ()
395382 if spock_cls in self .ref_2_resolve :
396383 # iterate over the mapped refs to swap values -- using the var resolver
397384 # to get the correct values
@@ -406,11 +393,10 @@ def resolve(self, spock_cls: str, spock_space: Dict) -> Dict:
406393 )
407394 # Swap the value to the replaced version
408395 self .cls_map [spock_cls ][ref ["val" ]] = typed_val
409- # Get a set of all changed variables and attempt to cast them
396+ # Get a set of all changed variables
410397 changed_vars = {n ["val" ] for n in self .ref_map [spock_cls ]}
411- self ._cast_all_maps (spock_cls , changed_vars )
412398 # Return the field dict
413- return self .cls_map [spock_cls ]
399+ return self .cls_map [spock_cls ], changed_vars
414400
415401 def _build (self ) -> Tuple [Dict , Dict ]:
416402 """Builds a dictionary of nodes and their edges (essentially builds the DAG)
0 commit comments