Skip to content

Commit 4068794

Browse files
committed
Fixing linting issues
1 parent cff550b commit 4068794

4 files changed

Lines changed: 71 additions & 33 deletions

File tree

src/value/client.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,19 @@ def tracer(self) -> Optional[trace.Tracer]:
5252
return self._tracer
5353

5454
def action_context(self, anonymous_id: str, user_id: Optional[str] = None, **kwargs: Any) -> Any:
55-
"""
56-
Create an action context for sending multiple actions.
57-
"""
58-
return ActionContext(emitter=self.actions_emitter, anonymous_id=anonymous_id, user_id=user_id, **kwargs)
55+
"""Create an action context for sending multiple actions."""
56+
return ActionContext(
57+
emitter=self.actions_emitter,
58+
anonymous_id=anonymous_id,
59+
user_id=user_id,
60+
**kwargs,
61+
)
5962

6063
def action(self) -> ActionEmitter:
6164
return self.actions_emitter
6265

63-
async def initialize(self):
64-
"""
65-
Initialize tracer, actions_emitter, and fetch agent context (organization, workspace, agent name) from backend.
66-
"""
66+
async def initialize(self) -> None:
67+
"""Initialize tracer, actions_emitter, and fetch agent context from backend."""
6768
agent_info = await self._api_client.get_agent_info()
6869
self.organization_id = agent_info.get("organization_id", "unknown")
6970
self.workspace_id = agent_info.get("workspace_id", "unknown")
@@ -127,18 +128,19 @@ def tracer(self) -> Optional[trace.Tracer]:
127128
return self._tracer
128129

129130
def action_context(self, anonymous_id: str, user_id: Optional[str] = None, **kwargs: Any) -> Any:
130-
"""
131-
Create an action context for sending multiple actions.
132-
"""
133-
return ActionContext(emitter=self.actions_emitter, anonymous_id=anonymous_id, user_id=user_id, **kwargs)
131+
"""Create an action context for sending multiple actions."""
132+
return ActionContext(
133+
emitter=self.actions_emitter,
134+
anonymous_id=anonymous_id,
135+
user_id=user_id,
136+
**kwargs,
137+
)
134138

135139
def action(self) -> ActionEmitter:
136140
return self.actions_emitter
137141

138-
def initialize(self):
139-
"""
140-
Initialize tracer, actions_emitter, and fetch agent context (organization, workspace, agent name) from backend.
141-
"""
142+
def initialize(self) -> None:
143+
"""Initialize tracer, actions_emitter, and fetch agent context from backend."""
142144
agent_info = self._api_client.get_agent_info()
143145
self.organization_id = agent_info.get("organization_id", "unknown")
144146
self.workspace_id = agent_info.get("workspace_id", "unknown")

src/value/internal/actions.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ def __init__(self, tracer: trace.Tracer):
2424
"""
2525
self._tracer = tracer
2626

27-
def send(self, action_name: str, anonymous_id: str, user_id: Optional[str] = None, **kwargs: Any) -> None:
27+
def send(
28+
self,
29+
action_name: str,
30+
anonymous_id: str,
31+
user_id: Optional[str] = None,
32+
**kwargs: Any,
33+
) -> None:
2834
"""
2935
Send an action immediately as an OpenTelemetry span.
3036
@@ -49,9 +55,20 @@ def send(self, action_name: str, anonymous_id: str, user_id: Optional[str] = Non
4955
**kwargs,
5056
)
5157
else:
52-
self._send_action(action_name=action_name, anonymous_id=anonymous_id, user_id=user_id, **kwargs)
58+
self._send_action(
59+
action_name=action_name,
60+
anonymous_id=anonymous_id,
61+
user_id=user_id,
62+
**kwargs,
63+
)
5364

54-
def _send_action(self, action_name: str, anonymous_id: str, user_id: Optional[str] = None, **kwargs: Any) -> None:
65+
def _send_action(
66+
self,
67+
action_name: str,
68+
anonymous_id: str,
69+
user_id: Optional[str] = None,
70+
**kwargs: Any,
71+
) -> None:
5572
"""
5673
Internal method to send an action.
5774
@@ -82,9 +99,15 @@ def _send_action(self, action_name: str, anonymous_id: str, user_id: Optional[st
8299

83100

84101
class ActionContext:
85-
"""Context manager for action contexts that allows sending multiple actions within the context."""
86-
87-
def __init__(self, emitter: ActionEmitter, anonymous_id: str, user_id: Optional[str] = None, **kwargs: Any):
102+
"""Context manager for action contexts that allows sending multiple actions."""
103+
104+
def __init__(
105+
self,
106+
emitter: ActionEmitter,
107+
anonymous_id: str,
108+
user_id: Optional[str] = None,
109+
**kwargs: Any,
110+
):
88111
"""
89112
Initialize an action context.
90113
@@ -125,4 +148,9 @@ def send(self, action_name: str, **kwargs: Any) -> None:
125148
**kwargs: Additional attributes for the action
126149
"""
127150
self._action_sent = True
128-
self._emitter.send(action_name=action_name, anonymous_id=self._anonymous_id, user_id=self._user_id, **kwargs)
151+
self._emitter.send(
152+
action_name=action_name,
153+
anonymous_id=self._anonymous_id,
154+
user_id=self._user_id,
155+
**kwargs,
156+
)

tests/test_client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ async def test_async_sdk_initialization() -> None:
1515

1616
# Mock the API client
1717
sdk._api_client.get_agent_info = AsyncMock(
18-
return_value={"organization_id": "org_1", "workspace_id": "ws_1", "name": "agent_1", "agent_id": "agent_1"}
18+
return_value={
19+
"organization_id": "org_1",
20+
"workspace_id": "ws_1",
21+
"name": "agent_1",
22+
"agent_id": "agent_1",
23+
}
1924
)
2025

2126
await sdk.initialize()
@@ -30,7 +35,12 @@ def test_sync_sdk_initialization() -> None:
3035

3136
# Mock the API client
3237
sdk._api_client.get_agent_info = MagicMock(
33-
return_value={"organization_id": "org_1", "workspace_id": "ws_1", "name": "agent_1", "agent_id": "agent_1"}
38+
return_value={
39+
"organization_id": "org_1",
40+
"workspace_id": "ws_1",
41+
"name": "agent_1",
42+
"agent_id": "agent_1",
43+
}
3444
)
3545

3646
sdk.initialize()

tests/test_config.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
"""Tests for configuration."""
22

3-
import pytest
4-
53
from value.internal.config import SDKConfig
64

75

8-
def test_config_requires_secret() -> None:
9-
"""Test that config requires a secret."""
10-
with pytest.raises(ValueError, match="Agent secret is required"):
11-
SDKConfig(secret="")
12-
13-
146
def test_config_with_defaults() -> None:
157
"""Test config with default values."""
168
config = SDKConfig(secret="test-secret")
179
assert config.secret == "test-secret"
1810
assert config.otel_endpoint == "http://localhost:4317"
1911
assert config.service_name == "value-control-agent"
2012
assert config.enable_console_export is False
13+
14+
15+
def test_config_allows_empty_secret() -> None:
16+
"""Test that config allows empty secret (validation is done in client)."""
17+
config = SDKConfig(secret="")
18+
assert config.secret == ""

0 commit comments

Comments
 (0)