mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-28 02:23:52 +02:00
change req in exp
This commit is contained in:
parent
790ff55981
commit
4650b7bdf1
4 changed files with 71 additions and 15 deletions
|
|
@ -19,9 +19,24 @@ def check_methods(C, *methods):
|
|||
return True
|
||||
|
||||
|
||||
def get_func_full_name(func, *args) -> str:
|
||||
if inspect.ismethod(func) or (inspect.isfunction(func) and "self" in inspect.signature(func).parameters):
|
||||
cls_name = args[0].__class__.__name__
|
||||
return f"{func.__module__}.{cls_name}.{func.__name__}"
|
||||
def get_class_name(func, *args) -> str:
|
||||
"""Returns the class name of the object that a method belongs to.
|
||||
|
||||
return f"{func.__module__}.{func.__name__}"
|
||||
- If `func` is a bound method, extracts the class name directly from the method.
|
||||
- If `func` is an unbound method and `args` are provided, assumes the first argument is `self` and extracts the class name.
|
||||
- Returns an empty string if neither condition is met.
|
||||
"""
|
||||
if inspect.ismethod(func):
|
||||
return func.__self__.__class__.__name__
|
||||
|
||||
if inspect.isfunction(func) and "self" in inspect.signature(func).parameters and args:
|
||||
return args[0].__class__.__name__
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
def get_func_or_method_name(func, *args) -> str:
|
||||
"""Function name, or method name with class name."""
|
||||
cls_name = get_class_name(func, *args)
|
||||
|
||||
return f"{cls_name}.{func.__name__}" if cls_name else f"{func.__name__}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue