Skip to content

Commit f37afa9

Browse files
foleydangclaude
andcommitted
fix: resolve pylint warnings in agentstudio test files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b1c4be8 commit f37afa9

2 files changed

Lines changed: 40 additions & 21 deletions

File tree

tests/unit/test_agentstudio_skills.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
# pylint: disable=protected-access
23
"""Skill resource shape & auto-upload compatibility.
34
45
Tests create a client with a mocked transport and patch Files.upload
@@ -23,27 +24,32 @@ def __init__(self):
2324
def request(self, method, path, **kwargs):
2425
self.calls.append({"method": method, "path": path, **kwargs})
2526
if "/versions" in path:
26-
return APIResponse(data={"id": "skv_1", "skill_id": "skl_1", "version": 1}, request_id="req_2")
27+
return APIResponse(
28+
data={"id": "skv_1", "skill_id": "skl_1", "version": 1},
29+
request_id="req_2",
30+
)
2731
if path == "/skills":
28-
return APIResponse(data={"id": "skl_1", "name": "demo"}, request_id="req_1")
32+
return APIResponse(
33+
data={"id": "skl_1", "name": "demo"}, request_id="req_1"
34+
)
2935
return APIResponse(data={}, request_id=None)
3036

3137

32-
@pytest.fixture
33-
def client():
38+
@pytest.fixture(name="client")
39+
def _client_fixture():
3440
"""Create a client with a recording transport."""
3541
c = Client(api_key="test-key")
3642
c._transport = _Tx()
3743
return c
3844

3945

40-
@pytest.fixture
41-
def fake_upload(client, monkeypatch):
46+
@pytest.fixture(name="fake_upload")
47+
def _fake_upload_fixture(client, monkeypatch):
4248
"""Patch Files.upload on the client's files instance to record calls."""
4349
calls: List[Dict[str, Any]] = []
4450
file_id_holder = {"id": "file_auto"}
4551

46-
def _upload(self_files, file, *, mime_type=None, **kwargs):
52+
def _upload(_self_files, file, *, mime_type=None, **_kwargs):
4753
calls.append({"file": file, "mime_type": mime_type})
4854

4955
class _F:
@@ -111,7 +117,9 @@ def test_skill_versions_create_with_file_id_no_upload(client, fake_upload):
111117
assert body == {"file_id": "file_existing"}
112118

113119

114-
def test_skill_versions_create_explicit_mime_type_overrides(client, fake_upload):
120+
def test_skill_versions_create_explicit_mime_type_overrides(
121+
client, fake_upload
122+
):
115123
upload_calls, _ = fake_upload
116124

117125
sv = SkillVersions(client)

tests/unit/test_agentstudio_tools.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
"""Tests for the @tool decorator schema synthesis and JSON Schema validation."""
2+
"""@tool decorator schema synthesis and JSON Schema validation."""
33

44
from typing import List, Optional
55

@@ -42,17 +42,21 @@ def get_weather(city: str, unit: str = "C") -> str:
4242
def test_tool_decorator_optional_and_list():
4343
@tool(name="search", description="Custom desc")
4444
def _search(q: str, limit: Optional[int] = None, tags: List[str] = None):
45-
return []
45+
return [q, limit, tags]
4646

4747
spec = _search.__tool_spec__
4848
assert spec.name == "search"
4949
assert spec.description == "Custom desc"
5050
props = spec.parameters["properties"]
5151
assert props["q"] == {"type": "string"}
52-
# Optional[int] -> integer with default=None (API needs to know it's optional)
52+
# Optional[int] -> integer with default=None
5353
assert props["limit"] == {"type": "integer", "default": None}
5454
# List[str] -> array of strings
55-
assert props["tags"] == {"type": "array", "items": {"type": "string"}, "default": None}
55+
assert props["tags"] == {
56+
"type": "array",
57+
"items": {"type": "string"},
58+
"default": None,
59+
}
5660
assert spec.parameters["required"] == ["q"]
5761

5862

@@ -63,7 +67,9 @@ def identity(text: str) -> str:
6367
return text
6468

6569
desc = identity.__tool_spec__.to_descriptor()
66-
assert "type" not in desc, "BMA backend does not accept 'type' field for custom tools"
70+
assert (
71+
"type" not in desc
72+
), "BMA backend does not accept 'type' field for custom tools"
6773
assert desc["name"] == "identity"
6874
assert desc["input_schema"]["properties"]["text"] == {"type": "string"}
6975

@@ -91,7 +97,7 @@ def test_default_value_is_emitted_into_schema():
9197
@tool
9298
def search(q: str, limit: int = 10) -> str:
9399
"""Search the index."""
94-
return ""
100+
return f"{q}{limit}"
95101

96102
schema = search.__tool_spec__.parameters
97103
_validate(schema)
@@ -103,20 +109,22 @@ def test_optional_strips_none_keeps_inner_type():
103109
@tool
104110
def lookup(name: str, hint: Optional[int] = None) -> str:
105111
"""Look something up."""
106-
return ""
112+
return f"{name}{hint}"
107113

108114
schema = lookup.__tool_spec__.parameters
109115
_validate(schema)
110116
assert schema["properties"]["hint"]["type"] == "integer"
111-
assert schema["properties"]["hint"]["default"] is None # None default is preserved
117+
assert (
118+
schema["properties"]["hint"]["default"] is None
119+
) # None default is preserved
112120
assert "hint" not in schema["required"]
113121

114122

115123
def test_list_inner_type_is_validated():
116124
@tool
117125
def tag(names: List[str]) -> str:
118126
"""Tag inputs."""
119-
return ""
127+
return str(names)
120128

121129
schema = tag.__tool_spec__.parameters
122130
_validate(schema)
@@ -135,14 +143,17 @@ def make_order(item: str, qty: int = 1) -> str:
135143
item: SKU identifier of the product to order.
136144
qty: How many units to request. Defaults to 1.
137145
"""
138-
return ""
146+
return f"{item}{qty}"
139147

140148
schema = make_order.__tool_spec__.parameters
141149
_validate(schema)
142150
assert schema["properties"]["item"]["description"] == (
143151
"SKU identifier of the product to order."
144152
)
145-
assert "How many units to request" in schema["properties"]["qty"]["description"]
153+
assert (
154+
"How many units to request"
155+
in schema["properties"]["qty"]["description"]
156+
)
146157
# Top-level summary trims the Args section
147158
assert make_order.__tool_spec__.description == "Place a supply order."
148159

@@ -155,7 +166,7 @@ def fetch(url: str, timeout: float = 5.0) -> str:
155166
:param url: The fully qualified URL to download.
156167
:param timeout: Per-request timeout in seconds.
157168
"""
158-
return ""
169+
return f"{url}{timeout}"
159170

160171
schema = fetch.__tool_spec__.parameters
161172
_validate(schema)
@@ -174,7 +185,7 @@ def test_descriptor_round_trip_validates_arguments():
174185
@tool
175186
def ping(host: str, count: int = 1) -> str:
176187
"""Ping a host."""
177-
return ""
188+
return f"{host}{count}"
178189

179190
schema = ping.__tool_spec__.to_descriptor()["input_schema"]
180191
_validate(schema)

0 commit comments

Comments
 (0)