@@ -577,37 +577,40 @@ def _handle_assign(node: ast.Assign, context: EvaluationContext):
577577
578578 # Before starred
579579 for i in range (star_or_last_idx ):
580- transient_locals [targets [i ].id ] = values [i ]
581580 # Check for self.x assignment
582581 if _is_instance_attribute_assignment (targets [i ], context ):
583582 class_transients [targets [i ].attr ] = values [i ]
583+ else :
584+ transient_locals [targets [i ].id ] = values [i ]
584585
585586 # Starred if exists
586587 if starred :
587588 end = len (values ) - (len (targets ) - star_or_last_idx - 1 )
588- transient_locals [targets [star_or_last_idx ].value .id ] = values [
589- star_or_last_idx :end
590- ]
591589 if _is_instance_attribute_assignment (
592590 targets [star_or_last_idx ], context
593591 ):
594592 class_transients [targets [star_or_last_idx ].attr ] = values [
595593 star_or_last_idx :end
596594 ]
595+ else :
596+ transient_locals [targets [star_or_last_idx ].value .id ] = values [
597+ star_or_last_idx :end
598+ ]
597599
598600 # After starred
599601 for i in range (star_or_last_idx + 1 , len (targets )):
600- transient_locals [targets [i ].id ] = values [
601- len (values ) - (len (targets ) - i )
602- ]
603602 if _is_instance_attribute_assignment (targets [i ], context ):
604603 class_transients [targets [i ].attr ] = values [
605604 len (values ) - (len (targets ) - i )
606605 ]
606+ else :
607+ transient_locals [targets [i ].id ] = values [
608+ len (values ) - (len (targets ) - i )
609+ ]
607610 else :
608611 if _is_instance_attribute_assignment (target , context ):
609612 class_transients [target .attr ] = value
610- elif hasattr ( target , "id" ) :
613+ else :
611614 transient_locals [target .id ] = value
612615 return None
613616
@@ -698,7 +701,6 @@ def eval_node(node: Union[ast.AST, None], context: EvaluationContext):
698701 if func_context .class_transients is not None :
699702 if not is_static and not is_classmethod :
700703 func_context .instance_arg_name = node .args .args [0 ].arg
701- print ("setting " , func_context .instance_arg_name )
702704
703705 return_type = eval_node (node .returns , context = context )
704706
@@ -868,6 +870,12 @@ def dummy_function(*args, **kwargs):
868870 if isinstance (node , ast .Name ):
869871 return _eval_node_name (node .id , context )
870872 if isinstance (node , ast .Attribute ):
873+ if (
874+ context .class_transients is not None
875+ and isinstance (node .value , ast .Name )
876+ and node .value .id == context .instance_arg_name
877+ ):
878+ return context .class_transients .get (node .attr )
871879 value = eval_node (node .value , context )
872880 if policy .can_get_attr (value , node .attr ):
873881 return getattr (value , node .attr )
@@ -930,7 +938,7 @@ def _merge_values(values):
930938 if type (v ) is not dict :
931939 continue
932940 for k , val in v .items ():
933- key_values .setdefault (k , []).append (val ) # Simpler than if-check
941+ key_values .setdefault (k , []).append (val )
934942
935943 merged_items = {k : _merge_values (vals ) for k , vals in key_values .items ()}
936944
0 commit comments