Skip to content

Commit 274b363

Browse files
author
mq-bot
committed
fix test errors
1 parent 70b166a commit 274b363

File tree

9 files changed

+16
-19
lines changed

9 files changed

+16
-19
lines changed

metagpt/actions/action_node.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,23 +567,23 @@ async def xml_fill(self, context: str, images: Optional[Union[str, list[str]]] =
567567
raw_value = match.group(1).strip()
568568
field_type = field_types.get(field_name)
569569

570-
if field_type == str:
570+
if field_type is str:
571571
extracted_data[field_name] = raw_value
572-
elif field_type == int:
572+
elif field_type is int:
573573
try:
574574
extracted_data[field_name] = int(raw_value)
575575
except ValueError:
576576
extracted_data[field_name] = 0 # 或者其他默认值
577-
elif field_type == bool:
577+
elif field_type is bool:
578578
extracted_data[field_name] = raw_value.lower() in ("true", "yes", "1", "on", "True")
579-
elif field_type == list:
579+
elif field_type is list:
580580
try:
581581
extracted_data[field_name] = eval(raw_value)
582582
if not isinstance(extracted_data[field_name], list):
583583
raise ValueError
584584
except:
585585
extracted_data[field_name] = [] # 默认空列表
586-
elif field_type == dict:
586+
elif field_type is dict:
587587
try:
588588
extracted_data[field_name] = eval(raw_value)
589589
if not isinstance(extracted_data[field_name], dict):

metagpt/ext/sela/insights/solution_designer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class SolutionDesigner:
137137

138138
async def generate_solutions(self, dataset_info, dataset_name, save_analysis_pool=True):
139139
llm = LLM()
140-
if type(dataset_info) == dict:
140+
if isinstance(dataset_info, dict):
141141
description_prompt = DATASET_DESCRIPTION_SELA_PROMPT.format(
142142
dataset=dataset_info["description"],
143143
metadata=self.metadata_builder(dataset_info["metadata"]),

metagpt/roles/role.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,7 @@ def set_env(self, env: BaseEnvironment):
315315
self.llm.cost_manager = self.context.cost_manager
316316
self.set_actions(self.actions) # reset actions to update llm and prefix
317317

318-
@property
319-
def name(self):
320-
"""Get the role name"""
321-
return self._setting.name
318+
# Removed property `name` that redefined the field and violated F811
322319

323320
def _get_prefix(self):
324321
"""Get the role prefix"""

metagpt/utils/human_interaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def multilines_input(self, prompt: str = "Enter: ") -> str:
2828

2929
def check_input_type(self, input_str: str, req_type: Type) -> Tuple[bool, Any]:
3030
check_ret = True
31-
if req_type == str:
31+
if req_type is str:
3232
# required_type = str, just return True
3333
return check_ret, input_str
3434
try:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels==4.0.0
44
# Django==4.1.5
55
# docx==0.2.4
66
#faiss==1.5.3
7-
faiss_cpu==1.7.4
7+
faiss_cpu==1.12.0
88
fire==0.4.0
99
typer==0.9.0
1010
# godot==0.1.1

tests/metagpt/serialize_deserialize/test_environment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def test_environment_serdeser(context):
5353

5454
assert list(new_env.roles.values())[0].states == list(environment.roles.values())[0].states
5555
assert isinstance(list(environment.roles.values())[0].actions[0], ActionOK)
56-
assert type(list(new_env.roles.values())[0].actions[0]) == ActionOK
57-
assert type(list(new_env.roles.values())[0].actions[1]) == ActionRaise
56+
assert isinstance(list(new_env.roles.values())[0].actions[0], ActionOK)
57+
assert isinstance(list(new_env.roles.values())[0].actions[1], ActionRaise)
5858
assert list(new_env.roles.values())[0].rc.watch == role_c.rc.watch
5959

6060

@@ -86,7 +86,7 @@ def test_environment_serdeser_save(context):
8686
env_dict = read_json_file(env_path)
8787
new_env: Environment = Environment(**env_dict, context=context)
8888
assert len(new_env.roles) == 1
89-
assert type(list(new_env.roles.values())[0].actions[0]) == ActionOK
89+
assert isinstance(list(new_env.roles.values())[0].actions[0], ActionOK)
9090
assert list(new_env.roles.values())[0].rc.watch == role_c.rc.watch
9191

9292

tests/metagpt/serialize_deserialize/test_prepare_interview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ async def test_action_serdeser(context):
1616
new_action = PrepareInterview(**serialized_data, context=context)
1717

1818
assert new_action.name == "PrepareInterview"
19-
assert type(await new_action.run("python developer")) == ActionNode
19+
assert isinstance(await new_action.run("python developer"), ActionNode)

tests/metagpt/serialize_deserialize/test_team.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_team_deserialize(context):
4242
assert new_company.env.get_role(pm.profile) is not None
4343

4444
new_pm = new_company.env.get_role(pm.profile)
45-
assert type(new_pm) == ProductManager
45+
assert isinstance(new_pm, ProductManager)
4646
assert new_company.env.get_role(pm.profile) is not None
4747
assert new_company.env.get_role(arch.profile) is not None
4848

@@ -89,7 +89,7 @@ async def test_team_recover(mocker, context):
8989
new_role_c = new_company.env.get_role(role_c.profile)
9090
assert new_role_c.rc.memory == role_c.rc.memory
9191
assert new_role_c.rc.env != role_c.rc.env
92-
assert type(list(new_company.env.roles.values())[0].actions[0]) == ActionOK
92+
assert isinstance(list(new_company.env.roles.values())[0].actions[0], ActionOK)
9393

9494
new_company.run_project(idea)
9595
await new_company.run(n_round=4)

tests/metagpt/serialize_deserialize/test_write_review.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ async def test_action_serdeser(context):
5151
review = await new_action.run(TEMPLATE_CONTEXT)
5252

5353
assert new_action.name == "WriteReview"
54-
assert type(review) == ActionNode
54+
assert isinstance(review, ActionNode)
5555
assert review.instruct_content
5656
assert review.get("LGTM") in ["LGTM", "LBTM"]

0 commit comments

Comments
 (0)