| 13 | |
| 14 | |
| 15 | def 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 | |
| 31 | def function_or_method_to_string(func_or_method: Callable) -> str: |