diff --git a/examples/distributed/user_proxy_agent.py b/examples/distributed/user_proxy_agent.py index a3437de6a..cb27f3386 100644 --- a/examples/distributed/user_proxy_agent.py +++ b/examples/distributed/user_proxy_agent.py @@ -9,7 +9,7 @@ class UserProxyAgent(UserAgent): """User proxy agent class""" - def reply( # type: ignore [override] + def reply( # type: ignore[override] self, x: dict = None, required_keys: Optional[Union[list[str], str]] = None, diff --git a/src/agentscope/agents/rpc_agent.py b/src/agentscope/agents/rpc_agent.py index 59ac0d1ce..5ab3102a7 100644 --- a/src/agentscope/agents/rpc_agent.py +++ b/src/agentscope/agents/rpc_agent.py @@ -48,14 +48,14 @@ ) -def rpc_servicer_method( # type: ignore [no-untyped-def] +def rpc_servicer_method( # type: ignore[no-untyped-def] func, ): """A decorator used to identify that the specific method is an rpc agent servicer method, which can only be run in the rpc server process. """ - def inner(rpc_agent, msg): # type: ignore [no-untyped-def] + def inner(rpc_agent, msg): # type: ignore[no-untyped-def] if not rpc_agent.is_servicer: error_msg = f"Detect main process try to use rpc servicer method \ [{func.__name__}]" @@ -139,7 +139,7 @@ def reply(self, x: dict = None) -> dict: value=x.serialize() if x is not None else "", ) return PlaceholderMessage( - **deserialize(res_msg), # type: ignore [arg-type] + **deserialize(res_msg), # type: ignore[arg-type] ) def observe(self, x: Union[dict, Sequence[dict]]) -> None: @@ -147,7 +147,7 @@ def observe(self, x: Union[dict, Sequence[dict]]) -> None: self._launch_server() self.client.call_func( func_name="_observe", - value=serialize(x), # type: ignore [arg-type] + value=serialize(x), # type: ignore[arg-type] ) def stop(self) -> None: diff --git a/src/agentscope/models/__init__.py b/src/agentscope/models/__init__.py index c29697297..d60bff6ad 100644 --- a/src/agentscope/models/__init__.py +++ b/src/agentscope/models/__init__.py @@ -68,11 +68,11 @@ def _get_model_wrapper(model_type: str) -> Type[ModelWrapperBase]: `Type[ModelWrapperBase]`: The corresponding model wrapper class. """ if model_type in ModelWrapperBase.type_registry: - return ModelWrapperBase.type_registry[ # type: ignore [return-value] + return ModelWrapperBase.type_registry[ # type: ignore[return-value] model_type ] elif model_type in ModelWrapperBase.registry: - return ModelWrapperBase.registry[ # type: ignore [return-value] + return ModelWrapperBase.registry[ # type: ignore[return-value] model_type ] elif model_type in ModelWrapperBase.deprecated_type_registry: @@ -81,7 +81,7 @@ def _get_model_wrapper(model_type: str) -> Type[ModelWrapperBase]: f"Model type [{model_type}] will be deprecated in future releases," f" please use [{cls.model_type}] instead.", ) - return cls # type: ignore [return-value] + return cls # type: ignore[return-value] else: logger.warning( f"Unsupported model_type [{model_type}]," diff --git a/src/agentscope/pipelines/functional.py b/src/agentscope/pipelines/functional.py index d04a4596c..85f69373a 100644 --- a/src/agentscope/pipelines/functional.py +++ b/src/agentscope/pipelines/functional.py @@ -147,7 +147,7 @@ def forlooppipeline( # check condition if break_func(x): break - return x # type: ignore [return-value] + return x # type: ignore[return-value] def whilelooppipeline( @@ -176,4 +176,4 @@ def whilelooppipeline( x = _operators(loop_body_operators, x) # check condition i += 1 - return x # type: ignore [return-value] + return x # type: ignore[return-value] diff --git a/src/agentscope/utils/monitor.py b/src/agentscope/utils/monitor.py index b2911f77c..a66e9290f 100644 --- a/src/agentscope/utils/monitor.py +++ b/src/agentscope/utils/monitor.py @@ -648,7 +648,7 @@ def get_monitor( raise NotImplementedError( "Monitor with type [{type}] is not implemented.", ) - return cls._instance # type: ignore [return-value] + return cls._instance # type: ignore[return-value] @classmethod def flush(cls) -> None: diff --git a/tests/monitor_test.py b/tests/monitor_test.py index 3fc54470a..63ade5f09 100644 --- a/tests/monitor_test.py +++ b/tests/monitor_test.py @@ -73,8 +73,8 @@ def test_register_exists_remove(self) -> None: # metric content metric = self.monitor.get_metric("token_num") self.assertIsNotNone(metric) - self.assertEqual(metric["unit"], "token") # type: ignore [index] - self.assertEqual(metric["quota"], 1000) # type: ignore [index] + self.assertEqual(metric["unit"], "token") # type: ignore[index] + self.assertEqual(metric["quota"], 1000) # type:ignore[index] # remove a registered metric self.assertTrue(self.monitor.remove("token_num")) self.assertFalse(self.monitor.exists("token_num")) @@ -155,9 +155,9 @@ def test_get(self) -> None: self.assertIsNone(self.monitor.get_metric("token_num")) metric = self.monitor.get_metric("agentB.token_num") self.assertIsNotNone(metric) - self.assertEqual(metric["value"], 0) # type: ignore [index] - self.assertEqual(metric["unit"], "token") # type: ignore [index] - self.assertEqual(metric["quota"], 100) # type: ignore [index] + self.assertEqual(metric["value"], 0) # type: ignore[index] + self.assertEqual(metric["unit"], "token") # type: ignore[index] + self.assertEqual(metric["quota"], 100) # type: ignore[index] self.assertEqual(self.monitor.get_metrics(r"cost"), {}) agenta_metrics = self.monitor.get_metrics("agentA") self.assertEqual(len(agenta_metrics.keys()), 2) @@ -213,7 +213,7 @@ def test_register_budget(self) -> None: "agent_A.gpt-4", ) self.assertLess( - self.monitor.get_value( # type: ignore [arg-type] + self.monitor.get_value( # type: ignore[arg-type] "agent_A.gpt-4.cost", ), 5, @@ -227,7 +227,7 @@ def test_register_budget(self) -> None: ), ) self.assertEqual( - self.monitor.get_value( # type: ignore [arg-type] + self.monitor.get_value( # type: ignore[arg-type] "agent_A.gpt-4.cost", ), 3, diff --git a/tests/rpc_agent_test.py b/tests/rpc_agent_test.py index 18837270e..0d7e3ab06 100644 --- a/tests/rpc_agent_test.py +++ b/tests/rpc_agent_test.py @@ -21,7 +21,7 @@ class DemoRpcAgent(AgentBase): """A demo Rpc agent for test usage.""" - def __init__(self, **kwargs) -> None: # type: ignore [no-untyped-def] + def __init__(self, **kwargs) -> None: # type: ignore[no-untyped-def] super().__init__(**kwargs) self.id = 0 @@ -138,7 +138,7 @@ def test_single_rpc_agent_server(self) -> None: self.assertTrue(isinstance(placeholder_result, PlaceholderMessage)) self.assertEqual(placeholder_result.name, "a") self.assertEqual( - placeholder_result["name"], # type: ignore [call-overload] + placeholder_result["name"], # type: ignore[call-overload] "a", ) self.assertTrue( @@ -163,7 +163,7 @@ def test_single_rpc_agent_server(self) -> None: self.assertEqual(msg_result.content, msg.content) self.assertEqual(msg_result.id, 0) # check id increase - msg = agent_a(msg_result) # type: ignore [arg-type] + msg = agent_a(msg_result) # type: ignore[arg-type] self.assertEqual(msg.id, 1) def test_connect_to_an_existing_rpc_server(self) -> None: