[CI][RFC] Replace black-jupyter with ruff-format (#37210)

Co-authored-by: Alison Shao <a.shao@wustl.edu>
This commit is contained in:
Alex Nails
2026-09-02 19:46:08 -07:00
committed by GitHub
co-authored by Alison Shao
parent 2641e427be
commit 28262c20df
1411 changed files with 7766 additions and 8176 deletions
@@ -373,7 +373,7 @@ class TestInklingDetector(unittest.TestCase):
self.assertEqual(result.normal_text, "Here you go.")
def test_empty_name_is_allowed_on_the_canonical_path(self):
source = "<|content_invoke_tool_json|>" '{"name":"","args":{}}<|end_message|>'
source = '<|content_invoke_tool_json|>{"name":"","args":{}}<|end_message|>'
result = InklingDetector().detect_and_parse(source, self.tools)
self.assertEqual(len(result.calls), 1)
self.assertEqual(result.calls[0].name, "")
@@ -1305,7 +1305,6 @@ class TestLlama32Detector(unittest.TestCase):
class TestKimiK2Detector(unittest.TestCase):
def setUp(self):
"""Set up test tools and detector."""
self.tools = [
@@ -1374,7 +1373,6 @@ class TestKimiK2Detector(unittest.TestCase):
result = self.detector.parse_streaming_increment(chunk, self.tools)
for tool_call_chunk in result.calls:
if tool_call_chunk.tool_index is not None:
while len(tool_calls) <= tool_call_chunk.tool_index:
tool_calls.append({"name": "", "parameters": ""})
@@ -1423,7 +1421,6 @@ class TestKimiK2Detector(unittest.TestCase):
result = self.detector.parse_streaming_increment(chunk, self.tools)
for tool_call_chunk in result.calls:
if tool_call_chunk.tool_index is not None:
while len(tool_calls) <= tool_call_chunk.tool_index:
tool_calls.append({"name": "", "parameters": ""})
@@ -1458,7 +1455,6 @@ class TestKimiK2Detector(unittest.TestCase):
result = self.detector.parse_streaming_increment(chunk, self.tools)
for tool_call_chunk in result.calls:
if tool_call_chunk.tool_index is not None:
while len(tool_calls) <= tool_call_chunk.tool_index:
tool_calls.append({"name": "", "parameters": ""})
@@ -1531,7 +1527,7 @@ class TestDeepSeekV3Detector(unittest.TestCase):
"function<tool▁sep>",
"get_tour",
"ist_att",
"ractions\n```" 'json\n{"',
'ractions\n```json\n{"',
'city": "',
'Beijing"}\n',
"```<tool▁call▁end>",
@@ -1718,9 +1714,9 @@ class TestDeepSeekV32Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertGreater(num_tool_call_chunks, 8)
@@ -1773,9 +1769,9 @@ class TestDeepSeekV32Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertGreater(num_tool_call_chunks, 8)
self.assertEqual(len(tool_calls_by_index), 1)
@@ -1866,9 +1862,9 @@ class TestDeepSeekV32Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
# Verify that the no-parameter function was correctly parsed
self.assertEqual(
@@ -1926,9 +1922,9 @@ class TestDeepSeekV32Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
# Should still parse correctly even with whitespace-only content
self.assertEqual(
@@ -2128,9 +2124,9 @@ class TestDeepSeekV4Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertGreater(num_tool_call_chunks, 8)
@@ -4500,9 +4496,7 @@ class TestLfm2Detector(unittest.TestCase):
def test_reserved_kwarg_with_nested_quote_recovered(self):
"""A keyword-named parameter holding a nested-quote command needs
the rename and requote rewrites to compose."""
text = (
"<|tool_call_start|>[search(from='sed -n '1,5p' f.py')]" "<|tool_call_end|>"
)
text = "<|tool_call_start|>[search(from='sed -n '1,5p' f.py')]<|tool_call_end|>"
result = self.detector.detect_and_parse(text, self.tools)
self.assertEqual(len(result.calls), 1)
@@ -4720,9 +4714,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(len(tool_calls_by_index), 1)
self.assertEqual(tool_calls_by_index[0]["name"], "manage_user_memory")
@@ -4762,9 +4756,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(accumulated_text, "I'll help you.")
self.assertEqual(len(tool_calls_by_index), 1)
@@ -4802,9 +4796,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(len(tool_calls_by_index), 1)
self.assertEqual(tool_calls_by_index[0]["name"], "manage_user_memory")
@@ -4841,9 +4835,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(len(tool_calls_by_index), 1)
self.assertEqual(tool_calls_by_index[0]["name"], "get_weather")
@@ -4878,9 +4872,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
# Should have name but incomplete parameters
self.assertEqual(len(tool_calls_by_index), 1)
@@ -4916,9 +4910,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(accumulated_text, "I'll remember that.")
self.assertEqual(len(tool_calls_by_index), 1)
@@ -4961,9 +4955,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(len(tool_calls_by_index), 1)
self.assertEqual(tool_calls_by_index[0]["name"], "get_weather")
@@ -5011,9 +5005,9 @@ function call<|role_sep|>
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(accumulated_text, "I'll help you.")
self.assertEqual(len(tool_calls_by_index), 1)
@@ -5265,9 +5259,9 @@ class TestQwen25Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
return tool_calls_by_index
def test_streaming_multiple_tool_calls(self):
@@ -5515,9 +5509,9 @@ class TestGemma4Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
return normal_text, tool_calls_by_index
def test_streaming_multiple_tool_calls(self):
@@ -5556,9 +5550,9 @@ class TestGemma4Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertEqual(len(tool_calls_by_index), 2)
self.assertEqual(tool_calls_by_index[0]["name"], "get_weather")
@@ -5623,9 +5617,9 @@ class TestGemma4Detector(unittest.TestCase):
if call.name:
tool_calls_by_index[call.tool_index]["name"] = call.name
if call.parameters:
tool_calls_by_index[call.tool_index][
"parameters"
] += call.parameters
tool_calls_by_index[call.tool_index]["parameters"] += (
call.parameters
)
self.assertIn("Hello!", normal_text)
self.assertIn("Let me also check", normal_text)
self.assertEqual(len(tool_calls_by_index), 2)