diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index f74c32fea..356b9e33f 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -152,7 +152,7 @@ class Role(SerializationMixin, is_polymorphic_base=True): __hash__ = object.__hash__ # support Role as hashable type in `Environment.members` @model_validator(mode="after") - def check_subscription(self) -> set: + def check_subscription(self): if not self.subscription: self.subscription = {any_to_str(self), self.name} if self.name else {any_to_str(self)} return self diff --git a/metagpt/utils/common.py b/metagpt/utils/common.py index 5999b2e11..60acd7e3c 100644 --- a/metagpt/utils/common.py +++ b/metagpt/utils/common.py @@ -23,7 +23,7 @@ import sys import traceback import typing from pathlib import Path -from typing import Any, Callable, List, Tuple, Union, get_args, get_origin +from typing import Any, List, Tuple, Union, get_args, get_origin import aiofiles import loguru @@ -365,14 +365,14 @@ def get_class_name(cls) -> str: return f"{cls.__module__}.{cls.__name__}" -def any_to_str(val: str | Callable) -> str: +def any_to_str(val: Any) -> 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): + elif not callable(val): return get_class_name(type(val)) - - return get_class_name(val) + else: + return get_class_name(val) def any_to_str_set(val) -> set: