Skip to content

Commit 3ea1998

Browse files
committed
Fix linting errors in config_loader and tests
- Fix unused loop variable in tool_config_loader.py (B007) - Fix boolean comparison issues in test_agent_config.py (E712) - Fix line length issues in structured output tests (E501) - Fix unused variables in test files (F841) - Fix blind exception assertion in schema registry test (B017) - Add ValidationError import to schema registry test - All tests passing (1010 passed, 55 warnings)
1 parent 33f4410 commit 3ea1998

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

src/strands/experimental/config_loader/tools/tool_config_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ def _scan_module_for_tools(self, module: Any) -> List[Tuple[str, str]]:
15191519
tools = []
15201520

15211521
# Find @tool decorated functions
1522-
for name, obj in inspect.getmembers(module):
1522+
for _name, obj in inspect.getmembers(module):
15231523
if isinstance(obj, DecoratedFunctionTool):
15241524
tools.append((obj.tool_name, "decorated"))
15251525

tests/strands/agent/test_agent_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ def test_agent_config_boolean_parameters(self):
144144

145145
agent = Agent(config=config)
146146

147-
assert agent.record_direct_tool_call == False
148-
assert agent.load_tools_from_directory == True
147+
assert not agent.record_direct_tool_call
148+
assert agent.load_tools_from_directory
149149

150150
def test_agent_config_boolean_parameter_override(self):
151151
"""Test that boolean parameters can be overridden."""
@@ -158,7 +158,7 @@ def test_agent_config_boolean_parameter_override(self):
158158
# Override boolean parameter
159159
agent = Agent(config=config, record_direct_tool_call=True)
160160

161-
assert agent.record_direct_tool_call == True
161+
assert agent.record_direct_tool_call
162162

163163
def test_agent_config_mixed_parameters(self):
164164
"""Test mixing config and individual parameters."""
@@ -236,8 +236,8 @@ def test_agent_config_with_all_parameters(self):
236236
assert agent.name == "Comprehensive Agent"
237237
assert agent.description == "Agent with comprehensive configuration"
238238
assert agent.agent_id == "comprehensive_agent_001"
239-
assert agent.record_direct_tool_call == False
240-
assert agent.load_tools_from_directory == False
239+
assert not agent.record_direct_tool_call
240+
assert not agent.load_tools_from_directory
241241

242242
@patch("strands.agent.agent.yaml.safe_load")
243243
def test_agent_config_yaml_load_error(self, mock_yaml_load):

tests/strands/experimental/config_loader/agent/test_agent_config_loader_structured_output.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@ def test_load_agent_with_python_class_reference(self, mock_agent_class):
7474
"name": "test_agent",
7575
"model": "test_model",
7676
"system_prompt": "Test prompt",
77-
"structured_output": "tests.strands.experimental.config_loader.agent.test_agent_config_loader_structured_output.TestBusinessModel",
77+
"structured_output": (
78+
"tests.strands.experimental.config_loader.agent."
79+
"test_agent_config_loader_structured_output.TestBusinessModel"
80+
),
7881
}
7982

80-
agent = self.loader.load_agent(config)
83+
self.loader.load_agent(config)
8184

8285
# Verify structured output was configured with the Python class
8386
assert hasattr(mock_agent, "_structured_output_schema")
@@ -111,7 +114,7 @@ def test_load_agent_with_detailed_structured_output_config(self, mock_agent_clas
111114
},
112115
}
113116

114-
agent = self.loader.load_agent(config)
117+
self.loader.load_agent(config)
115118

116119
# Verify structured output was configured
117120
assert hasattr(mock_agent, "_structured_output_schema")
@@ -152,7 +155,7 @@ def test_load_agent_with_external_schema_file(self, mock_agent_class):
152155
"structured_output": "Product",
153156
}
154157

155-
agent = self.loader.load_agent(config)
158+
self.loader.load_agent(config)
156159

157160
# Verify structured output was configured
158161
assert hasattr(mock_agent, "_structured_output_schema")
@@ -190,7 +193,7 @@ def test_load_agent_with_structured_output_defaults(self, mock_agent_class):
190193
},
191194
}
192195

193-
agent = self.loader.load_agent(config)
196+
self.loader.load_agent(config)
194197

195198
# Verify defaults were merged with specific config
196199
validation_config = mock_agent._structured_output_validation
@@ -225,10 +228,10 @@ def test_load_multiple_agents_with_shared_schemas(self, mock_agent_class):
225228
agent2_config = {**base_config, "name": "agent2", "model": "test_model", "structured_output": "SharedSchema"}
226229

227230
# Load first agent (should load schemas)
228-
agent1 = self.loader.load_agent(agent1_config)
231+
self.loader.load_agent(agent1_config)
229232

230233
# Load second agent (should reuse schemas)
231-
agent2 = self.loader.load_agent(agent2_config)
234+
self.loader.load_agent(agent2_config)
232235

233236
# Both agents should have the same schema class
234237
assert hasattr(mock_agent1, "_structured_output_schema")
@@ -376,7 +379,7 @@ def test_convenience_method_creation(self, mock_agent_class):
376379
"structured_output": "CustomerProfile",
377380
}
378381

379-
agent = self.loader.load_agent(config)
382+
self.loader.load_agent(config)
380383

381384
# Verify convenience method was created
382385
assert hasattr(mock_agent, "extract_customerprofile")

tests/strands/experimental/config_loader/agent/test_integration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def test_load_agent_from_yaml_config(self):
3939
config = {
4040
"agent": {
4141
"model": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
42-
"system_prompt": "You're a helpful assistant. You can do simple math calculation, and tell the weather.",
42+
"system_prompt": (
43+
"You're a helpful assistant. You can do simple math calculation, and tell the weather."
44+
),
4345
"tools": [{"name": "weather_tool.weather"}],
4446
}
4547
}

tests/strands/experimental/config_loader/agent/test_schema_registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pytest
99
import yaml
10-
from pydantic import BaseModel
10+
from pydantic import BaseModel, ValidationError
1111

1212
from strands.experimental.config_loader.agent.schema_registry import SchemaRegistry
1313

@@ -351,5 +351,5 @@ def test_multiple_schemas_same_name(self):
351351
assert instance2.field2 == 42
352352

353353
# Should not be able to create instance with old schema
354-
with pytest.raises(Exception): # ValidationError or AttributeError
354+
with pytest.raises((ValidationError, AttributeError, TypeError)):
355355
model2(field1="test")

tests/strands/experimental/config_loader/graph/test_graph_config_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test_serialize_graph(self):
118118
agent = Agent(name="test_agent", model="us.amazon.nova-lite-v1:0")
119119

120120
# Mock the Graph creation since we need to avoid complex dependencies
121-
with patch("strands.multiagent.graph.Graph") as MockGraph:
121+
with patch("strands.multiagent.graph.Graph"):
122122
mock_graph = Mock()
123123

124124
# Create a proper GraphNode with the agent

0 commit comments

Comments
 (0)