def propagate_attributes(old_function, new_function):
 if hasattr(old_function, 'return_type'):
  new_function.func_name = old_function.func_name
  new_function.return_type = old_function.return_type
  new_function.arg_types = old_function.arg_types
 if hasattr(old_function, 'CustomAttributeBuilders'):
  new_function.CustomAttributeBuilders = old_function.CustomAttributeBuilders
 if hasattr(old_function, 'CustomAttributeBuilders'):
  new_function.DllImportAttributeDecorator = old_function.DllImportAttributeDecorator

def propagate_attributes ( old_function , new_function ) : if hasattr ( old_function , 'return_type' ) : new_function . func_name = old_function . func_name new_function . return_type = old_function . return_type new_function . arg_types = old_function . arg_types if hasattr ( old_function , 'CustomAttributeBuilders' ) : new_function . CustomAttributeBuilders = old_function . CustomAttributeBuilders if hasattr ( old_function , 'CustomAttributeBuilders' ) : new_function . DllImportAttributeDecorator = old_function . DllImportAttributeDecorator
use this if you replace a function in a type with clrinterface or clrclass as the metaclass .