Skip to content

Commit ffc7741

Browse files
committed
improved formatting
1 parent 6229b14 commit ffc7741

22 files changed

+2382
-1092
lines changed

debug/find_inprocess_bug.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import inspect
8+
import platform
89
import sys
910
from datetime import UTC
1011
from pathlib import Path

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ omit = [
8383
"*/tests/*",
8484
"*/test_*.py",
8585
"*/__main__.py",
86+
"*/sample_tools/*",
87+
"src/sample_tools/*",
8688
]
8789

8890
[tool.coverage.report]
@@ -100,6 +102,10 @@ exclude_lines = [
100102
skip_covered = false
101103
show_missing = true
102104
precision = 2
105+
omit = [
106+
"*/sample_tools/*",
107+
"src/sample_tools/*",
108+
]
103109

104110
[tool.mypy]
105111
python_version = "3.11"

ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Ruff configuration for chuk-tool-processor
22
line-length = 120
33
target-version = "py311"
4+
extend-exclude = ["debug", "examples"]
45

56
[lint]
67
select = [

src/chuk_tool_processor/logging/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ def _initialize_shutdown_fixes():
3535
# Import internal modules in correct order to avoid circular imports
3636
# First, formatter has no internal dependencies
3737
# Second, context only depends on formatter
38-
from .context import LogContext, StructuredAdapter, get_logger, log_context
39-
from .formatter import StructuredFormatter
38+
from .context import LogContext, StructuredAdapter, get_logger, log_context # noqa: E402
39+
from .formatter import StructuredFormatter # noqa: E402
4040

4141
# Third, helpers depend on context
42-
from .helpers import log_context_span, log_tool_call, request_logging
42+
from .helpers import log_context_span, log_tool_call, request_logging # noqa: E402
4343

4444
# Fourth, metrics depend on helpers and context
45-
from .metrics import MetricsLogger, metrics
45+
from .metrics import MetricsLogger, metrics # noqa: E402
4646

4747
__all__ = [
4848
"get_logger",
4949
"log_context",
5050
"LogContext",
51+
"StructuredAdapter",
5152
"log_context_span",
5253
"request_logging",
5354
"log_tool_call",

src/chuk_tool_processor/plugins/parsers/function_call_tool.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,23 @@ class FunctionCallPlugin(ParserPlugin):
3939
# Public API
4040
# --------------------------------------------------------------------- #
4141

42-
async def try_parse(self, raw: str | dict[str, Any]) -> list[ToolCall]:
42+
async def try_parse(self, raw: Any) -> list[ToolCall]:
43+
# Handle non-string, non-dict inputs gracefully
44+
if not isinstance(raw, str | dict):
45+
return []
46+
4347
payload: dict[str, Any] | None
4448

4549
# 1️⃣ Primary path ─ whole payload is JSON
4650
if isinstance(raw, dict):
4751
payload = raw
48-
else:
52+
elif isinstance(raw, str):
4953
try:
5054
payload = json.loads(raw)
5155
except json.JSONDecodeError:
5256
payload = None
57+
else:
58+
return []
5359

5460
calls: list[ToolCall] = []
5561

src/chuk_tool_processor/plugins/parsers/openai_tool.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ async def try_parse(self, raw: str | Any) -> list[ToolCall]: # noqa: D401
6161
# 2. Build ToolCall objects
6262
# ------------------------------------------------------------------ #
6363
calls: list[ToolCall] = []
64-
for entry in data["tool_calls"]:
64+
65+
# Ensure tool_calls is a list
66+
tool_calls = data.get("tool_calls", [])
67+
if not isinstance(tool_calls, list):
68+
return []
69+
70+
for entry in tool_calls:
6571
fn = entry.get("function", {})
6672
name = fn.get("name")
6773
args = fn.get("arguments", {})

src/chuk_tool_processor/registry/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
Async-native tool registry package for managing and accessing tool implementations.
44
"""
55

6-
import asyncio
7-
from typing import Optional
8-
96
from chuk_tool_processor.registry.decorators import discover_decorated_tools, ensure_registrations, register_tool
107
from chuk_tool_processor.registry.interface import ToolRegistryInterface
118
from chuk_tool_processor.registry.metadata import StreamingToolMetadata, ToolMetadata

src/chuk_tool_processor/registry/providers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import asyncio
77
import os
8-
from typing import Any, Dict, Optional
98

109
from chuk_tool_processor.registry.interface import ToolRegistryInterface
1110

0 commit comments

Comments
 (0)