Skip to content

Commit 034525b

Browse files
author
Alex Reibman
committed
Fix Ruff CI failures: remove unused variables and apply formatting
1 parent e5a59a7 commit 034525b

File tree

9 files changed

+32
-31
lines changed

9 files changed

+32
-31
lines changed

agentops/client/api/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
class TokenFetcher(Protocol):
1616
"""Protocol for token fetching functions"""
1717

18-
def __call__(self, api_key: str) -> str: ...
18+
def __call__(self, api_key: str) -> str:
19+
...
1920

2021

2122
class BaseApiClient:

agentops/client/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class Client:
4040
config: Config
4141
_initialized: bool
4242
_init_trace_context: Optional[TraceContext] = None # Stores the context of the auto-started trace
43-
_legacy_session_for_init_trace: Optional[Session] = (
44-
None # Stores the legacy Session wrapper for the auto-started trace
45-
)
43+
_legacy_session_for_init_trace: Optional[
44+
Session
45+
] = None # Stores the legacy Session wrapper for the auto-started trace
4646

4747
__instance = None # Class variable for singleton pattern
4848

agentops/instrumentation/agentic/google_adk/patch.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,16 @@ def _extract_llm_attributes(llm_request_dict: dict, llm_response: Any) -> dict:
304304
elif "function_call" in part:
305305
# This is a function call in the response
306306
func_call = part["function_call"]
307-
attributes[MessageAttributes.COMPLETION_TOOL_CALL_NAME.format(i=0, j=tool_call_index)] = (
308-
func_call.get("name", "")
309-
)
310-
attributes[MessageAttributes.COMPLETION_TOOL_CALL_ARGUMENTS.format(i=0, j=tool_call_index)] = (
311-
json.dumps(func_call.get("args", {}))
312-
)
307+
attributes[
308+
MessageAttributes.COMPLETION_TOOL_CALL_NAME.format(i=0, j=tool_call_index)
309+
] = func_call.get("name", "")
310+
attributes[
311+
MessageAttributes.COMPLETION_TOOL_CALL_ARGUMENTS.format(i=0, j=tool_call_index)
312+
] = json.dumps(func_call.get("args", {}))
313313
if "id" in func_call:
314-
attributes[MessageAttributes.COMPLETION_TOOL_CALL_ID.format(i=0, j=tool_call_index)] = (
315-
func_call["id"]
316-
)
314+
attributes[
315+
MessageAttributes.COMPLETION_TOOL_CALL_ID.format(i=0, j=tool_call_index)
316+
] = func_call["id"]
317317
tool_call_index += 1
318318

319319
if text_parts:

agentops/instrumentation/agentic/openai_agents/attributes/completion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def get_raw_response_attributes(response: Dict[str, Any]) -> Dict[str, Any]:
115115
result[MessageAttributes.COMPLETION_TOOL_CALL_NAME.format(i=j, j=k)] = function.get(
116116
"name", ""
117117
)
118-
result[MessageAttributes.COMPLETION_TOOL_CALL_ARGUMENTS.format(i=j, j=k)] = (
119-
function.get("arguments", "")
120-
)
118+
result[
119+
MessageAttributes.COMPLETION_TOOL_CALL_ARGUMENTS.format(i=j, j=k)
120+
] = function.get("arguments", "")
121121

122122
return result
123123

agentops/instrumentation/agentic/smolagents/attributes/model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ def get_model_attributes(
102102
if hasattr(return_value, "tool_calls") and return_value.tool_calls:
103103
for j, tool_call in enumerate(return_value.tool_calls):
104104
if hasattr(tool_call, "function"):
105-
attributes[MessageAttributes.COMPLETION_TOOL_CALL_NAME.format(i=0, j=j)] = (
106-
tool_call.function.name
107-
)
105+
attributes[
106+
MessageAttributes.COMPLETION_TOOL_CALL_NAME.format(i=0, j=j)
107+
] = tool_call.function.name
108108
if hasattr(tool_call.function, "arguments"):
109-
attributes[MessageAttributes.COMPLETION_TOOL_CALL_ARGUMENTS.format(i=0, j=j)] = (
110-
tool_call.function.arguments
111-
)
109+
attributes[
110+
MessageAttributes.COMPLETION_TOOL_CALL_ARGUMENTS.format(i=0, j=j)
111+
] = tool_call.function.arguments
112112
if hasattr(tool_call, "id"):
113113
attributes[MessageAttributes.COMPLETION_TOOL_CALL_ID.format(i=0, j=j)] = tool_call.id
114114

agentops/instrumentation/common/attributes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class IndexedAttribute(Protocol):
9898
formatting of attribute keys based on the indices.
9999
"""
100100

101-
def format(self, *, i: int, j: Optional[int] = None) -> str: ...
101+
def format(self, *, i: int, j: Optional[int] = None) -> str:
102+
...
102103

103104

104105
IndexedAttributeMap = Dict[IndexedAttribute, str] # target_attribute_key: source_attribute

examples/openai/o3_responses_example.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def make_decision_sync(self, scenario: str, available_actions: List[str], stream
120120
# Process streaming response
121121
tool_call = None
122122
tool_arguments = ""
123-
current_call_id = None
124123

125124
for event in response:
126125
if hasattr(event, "type"):
@@ -134,7 +133,7 @@ def make_decision_sync(self, scenario: str, available_actions: List[str], stream
134133
elif event.type == "response.output_item.added":
135134
# New tool call started
136135
if hasattr(event, "output_item") and event.output_item.type == "function_call":
137-
current_call_id = event.output_item.call_id
136+
pass # Tool call tracking handled elsewhere
138137
elif event.type == "response.completed":
139138
# Process final response
140139
if hasattr(event, "response") and hasattr(event.response, "output"):
@@ -267,7 +266,6 @@ async def make_decision_async(
267266
# Process streaming response
268267
tool_call = None
269268
tool_arguments = ""
270-
current_call_id = None
271269

272270
async for event in response:
273271
if hasattr(event, "type"):
@@ -281,7 +279,7 @@ async def make_decision_async(
281279
elif event.type == "response.output_item.added":
282280
# New tool call started
283281
if hasattr(event, "output_item") and event.output_item.type == "function_call":
284-
current_call_id = event.output_item.call_id
282+
pass # Tool call tracking handled elsewhere
285283
elif event.type == "response.completed":
286284
# Process final response
287285
if hasattr(event, "response") and hasattr(event.response, "output"):

tests/unit/instrumentation/openai_core/test_instrumentor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def test_instrument_method_wraps_response_api(self, instrumentor):
107107
instrumentor_obj._custom_wrap()
108108

109109
# Verify wrap_function_wrapper was called for Response API methods
110-
assert mock_wfw.call_count >= 2, (
111-
f"Expected at least 2 calls to wrap_function_wrapper, got {mock_wfw.call_count}"
112-
)
110+
assert (
111+
mock_wfw.call_count >= 2
112+
), f"Expected at least 2 calls to wrap_function_wrapper, got {mock_wfw.call_count}"
113113

114114
# Find Response API calls
115115
response_api_calls = []

tests/unit/sdk/instrumentation_tester.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def reset_trace_globals():
4545

4646
class HasAttributesViaProperty(Protocol):
4747
@property
48-
def attributes(self) -> Attributes: ...
48+
def attributes(self) -> Attributes:
49+
...
4950

5051

5152
class HasAttributesViaAttr(Protocol):

0 commit comments

Comments
 (0)