diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 00000000..3bfe71eb --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,10 @@ +version = 1 + +[[analyzers]] +name = "shell" + +[[analyzers]] +name = "python" + + [analyzers.meta] + runtime_version = "3.x.x" \ No newline at end of file diff --git a/swarms/tools/tool.py b/swarms/tools/tool.py index 1029a183..ade01166 100644 --- a/swarms/tools/tool.py +++ b/swarms/tools/tool.py @@ -34,7 +34,7 @@ from pydantic import ( Extra, Field, create_model, - root_validator, + model_validator, validate_arguments, ) from langchain.schema.runnable import ( @@ -276,7 +276,7 @@ class ChildTool(BaseTool): } return tool_input - @root_validator() + @model_validator(mode="after") def raise_deprecation(cls, values: Dict) -> Dict: """Raise deprecation warning if callback_manager is used.""" if values.get("callback_manager") is not None: diff --git a/tests/models/test_ssd_1b.py b/tests/models/test_ssd_1b.py index 35cc4864..8ea0182e 100644 --- a/tests/models/test_ssd_1b.py +++ b/tests/models/test_ssd_1b.py @@ -107,12 +107,20 @@ def test_ssd1b_generate_uuid(ssd1b_model): assert len(uuid_str) == 36 # UUID format -def test_ssd1b_rate_limited_call(ssd1b_model): +def test_ssd1b_rate_limited_call_connect(ssd1b_model): task = "A painting of a dog" image_url = ssd1b_model.rate_limited_call(task) assert isinstance(image_url, str) assert image_url.startswith("https://") +def test_ssd1b_rate_limited_call_ratelimit(ssd1b_model, mocker): + task = "A painting of a dog" + mocker.patch.object( + ssd1b_model, "__call__", side_effect=Exception("Rate limit exceeded") + ) + with pytest.raises(Exception, match="Rate limit exceeded"): + ssd1b_model.rate_limited_call(task) + # Test cases for additional scenarios and behaviors def test_ssd1b_dashboard_printing(ssd1b_model, capsys): diff --git a/tests/structs/test_flow.py b/tests/structs/test_flow.py index a8e1cf92..87e38b9d 100644 --- a/tests/structs/test_flow.py +++ b/tests/structs/test_flow.py @@ -347,7 +347,6 @@ def test_flow_response_filtering(flow_instance): def test_flow_undo_last(flow_instance): # Test the undo functionality response1 = flow_instance.run("Task 1") - response2 = flow_instance.run("Task 2") previous_state, message = flow_instance.undo_last() assert response1 == previous_state assert "Restored to" in message @@ -577,7 +576,6 @@ def test_flow_rollback(flow_instance): # Test rolling back to a previous state state1 = flow_instance.get_state() flow_instance.change_prompt("New prompt") - state2 = flow_instance.get_state() flow_instance.rollback_to_state(state1) assert ( flow_instance.get_current_prompt() == state1["current_prompt"] diff --git a/tests/swarms/test_multi_agent_collab.py b/tests/swarms/test_multi_agent_collab.py index e30358aa..ef75dc65 100644 --- a/tests/swarms/test_multi_agent_collab.py +++ b/tests/swarms/test_multi_agent_collab.py @@ -26,7 +26,7 @@ def test_collaboration_initialization(collaboration): assert callable(collaboration.select_next_speaker) assert collaboration.max_iters == 10 assert collaboration.results == [] - assert collaboration.logging == True + assert collaboration.logging def test_reset(collaboration): @@ -105,13 +105,6 @@ def test_set_interaction_rules(collaboration): assert collaboration.interaction_rules == rules -def test_set_interaction_rules(collaboration): - rules = {"rule1": "action1", "rule2": "action2"} - collaboration.set_interaction_rules(rules) - assert hasattr(collaboration, "interaction_rules") - assert collaboration.interaction_rules == rules - - def test_repr(collaboration): repr_str = repr(collaboration) assert isinstance(repr_str, str)