def _get_indirect_shadowing_information(contract): """ Obtain a string that describes variable shadowing for the given variable. None if no shadowing exists. :param var: The variable to collect shadowing information for. :param contract: The contract in which this variable is being analyzed. :return: Returns a string describing variable shadowing for the given variable. None if no shadowing exists. """ # If this variable is an overshadowing variable, we'll want to return information describing it. result = [] indirect_shadows = detect_c3_function_shadowing(contract) for winner, colliding_functions in indirect_shadows.items(): collision_steps = ', '.join([f.contract_declarer.name for f in colliding_functions] + [winner.contract_declarer.name]) result.append(f"'{winner.full_name}' collides in inherited contracts {collision_steps} where {winner.contract_declarer.name} is chosen.") return '\n'.join(result)
def _get_indirect_shadowing_information(contract): """ Obtain a string that describes variable shadowing for the given variable. None if no shadowing exists. :param var: The variable to collect shadowing information for. :param contract: The contract in which this variable is being analyzed. :return: Returns a string describing variable shadowing for the given variable. None if no shadowing exists. """ # If this variable is an overshadowing variable, we'll want to return information describing it. result = [] indirect_shadows = detect_c3_function_shadowing(contract) if indirect_shadows: for collision_set in sorted(indirect_shadows, key=lambda x: x[0][1].name): winner = collision_set[-1][1].contract_declarer.name collision_steps = [colliding_function.contract_declarer.name for _, colliding_function in collision_set] collision_steps = ', '.join(collision_steps) result.append(f"'{collision_set[0][1].full_name}' collides in inherited contracts {collision_steps} where {winner} is chosen.") return '\n'.join(result)