mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-02 20:32:38 +02:00
refactor: @cause_by.setter
This commit is contained in:
parent
1febf168e7
commit
d9775037b6
21 changed files with 73 additions and 123 deletions
|
|
@ -315,3 +315,13 @@ def get_object_name(obj) -> str:
|
|||
"""Return class name of the object"""
|
||||
cls = type(obj)
|
||||
return f"{cls.__module__}.{cls.__name__}"
|
||||
|
||||
|
||||
def any_to_str(val) -> str:
|
||||
"""Return the class name or the class name of the object, or 'val' if it's a string type."""
|
||||
if isinstance(val, str):
|
||||
return val
|
||||
if not callable(val):
|
||||
return get_object_name(val)
|
||||
|
||||
return get_class_name(val)
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/11/1
|
||||
@Author : mashenquan
|
||||
@File : named.py
|
||||
"""
|
||||
|
||||
|
||||
class Named:
|
||||
"""A base class with functions for converting classes to names and objects to class names."""
|
||||
|
||||
@classmethod
|
||||
def get_class_name(cls):
|
||||
"""Return class name"""
|
||||
return f"{cls.__module__}.{cls.__name__}"
|
||||
|
||||
def get_object_name(self):
|
||||
"""Return class name of the object"""
|
||||
cls = type(self)
|
||||
return f"{cls.__module__}.{cls.__name__}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue