MCPcopy Create free account
hub / github.com/HKUDS/AutoAgent / function_or_method_to_repr

Function function_or_method_to_repr

autoagent/flow/utils.py:15–28  ·  view source on GitHub ↗
(func_or_method: Callable)

Source from the content-addressed store, hash-verified

13
14
15def function_or_method_to_repr(func_or_method: Callable) -> str:
16 is_method = inspect.ismethod(func_or_method)
17 is_function = inspect.isfunction(func_or_method)
18 if not is_method and not is_function:
19 raise ValueError("Input must be a function or method")
20 module = func_or_method.__module__
21 name = func_or_method.__name__
22 line_number = inspect.getsourcelines(func_or_method)[1]
23
24 if is_method:
25 class_name = func_or_method.__self__.__class__.__name__
26 return f"{module}.l_{line_number}.{class_name}.{name}".strip()
27 else:
28 return f"{module}.l_{line_number}.{name}".strip()
29
30
31def function_or_method_to_string(func_or_method: Callable) -> str:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected