Skip to content

Commit e9767dd

Browse files
committed
Run make lint on repo
1 parent 392de40 commit e9767dd

107 files changed

Lines changed: 1409 additions & 2882 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.basedpyright/baseline.json

Lines changed: 453 additions & 1089 deletions
Large diffs are not rendered by default.

examples/ai_custom_alert_app/bin/setup_logging.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ def setup_logging(app_name: str) -> logging.Logger:
2626
logger = logging.getLogger(app_name)
2727
logger.setLevel(logging.DEBUG)
2828

29-
handler = logging.handlers.RotatingFileHandler(
30-
LOG_PATH, maxBytes=1024 * 1024, backupCount=5
31-
)
32-
handler.setFormatter(
33-
logging.Formatter(f"%(asctime)s %(levelname)s [{app_name}] %(message)s")
34-
)
29+
handler = logging.handlers.RotatingFileHandler(LOG_PATH, maxBytes=1024 * 1024, backupCount=5)
30+
handler.setFormatter(logging.Formatter(f"%(asctime)s %(levelname)s [{app_name}] %(message)s"))
3531
logger.addHandler(handler)
3632
return logger

examples/ai_custom_alert_app/bin/threat_level_assessment.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
# one that might not exist on the filesystem. In such case we unset the env, which
4141
# causes the default Certificate Authorities to be used instead.
4242
CA_TRUST_STORE = "/opt/splunk/openssl/cert.pem"
43-
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(
44-
CA_TRUST_STORE
45-
):
43+
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(CA_TRUST_STORE):
4644
del os.environ["SSL_CERT_FILE"]
4745

4846

@@ -86,9 +84,7 @@ class AgenticSeverityAssessment(BaseModel):
8684
recommended_action: str
8785

8886

89-
async def invoke_agent(
90-
service: client.Service, alert_data: AlertData
91-
) -> AgenticSeverityAssessment:
87+
async def invoke_agent(service: client.Service, alert_data: AlertData) -> AgenticSeverityAssessment:
9288
async with Agent(
9389
model=LLM_MODEL,
9490
system_prompt=SYSTEM_PROMPT,

examples/ai_custom_search_app/bin/agentic_reporting_csc.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from splunklib.searchcommands import (
3535
Configuration,
3636
Option,
37-
dispatch, # pyright: ignore[reportPrivateLocalImportUsage]
37+
dispatch,
3838
validators,
3939
)
4040
from splunklib.searchcommands.eventing_command import EventingCommand
@@ -43,9 +43,7 @@
4343
# one that might not exist on the filesystem. In such case we unset the env, which
4444
# causes the default Certificate Authorities to be used instead.
4545
CA_TRUST_STORE = "/opt/splunk/openssl/cert.pem"
46-
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(
47-
CA_TRUST_STORE
48-
):
46+
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(CA_TRUST_STORE):
4947
del os.environ["SSL_CERT_FILE"]
5048

5149
APP_NAME = "ai_custom_search_app"

examples/ai_custom_search_app/bin/setup_logging.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ def setup_logging(app_name: str) -> logging.Logger:
2727
logger = logging.getLogger(app_name)
2828
logger.setLevel(logging.DEBUG)
2929

30-
handler = logging.handlers.RotatingFileHandler(
31-
LOG_FILE, maxBytes=1024 * 1024, backupCount=5
32-
)
33-
handler.setFormatter(
34-
logging.Formatter(f"%(asctime)s %(levelname)s [{app_name}] %(message)s")
35-
)
30+
handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes=1024 * 1024, backupCount=5)
31+
handler.setFormatter(logging.Formatter(f"%(asctime)s %(levelname)s [{app_name}] %(message)s"))
3632
logger.addHandler(handler)
3733

3834
return logger

examples/ai_modinput_app/bin/agentic_weather.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
# one that might not exist on the filesystem. In such case we unset the env, which
4545
# causes the default Certificate Authorities to be used instead.
4646
CA_TRUST_STORE = "/opt/splunk/openssl/cert.pem"
47-
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(
48-
CA_TRUST_STORE
49-
):
47+
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(CA_TRUST_STORE):
5048
del os.environ["SSL_CERT_FILE"]
5149

5250

examples/ai_modinput_app/bin/setup_logging.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@ def setup_logging(app_name: str) -> logging.Logger:
2626
logger = logging.getLogger(app_name)
2727
logger.setLevel(logging.DEBUG)
2828

29-
handler = logging.handlers.RotatingFileHandler(
30-
LOG_FILE, maxBytes=1024 * 1024, backupCount=5
31-
)
32-
handler.setFormatter(
33-
logging.Formatter(f"%(asctime)s %(levelname)s [{app_name}] %(message)s")
34-
)
29+
handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes=1024 * 1024, backupCount=5)
30+
handler.setFormatter(logging.Formatter(f"%(asctime)s %(levelname)s [{app_name}] %(message)s"))
3531
logger.addHandler(handler)
3632

3733
return logger

splunklib/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
# To set the logging level of splunklib
2727
# ex. To enable debug logs, call this method with parameter 'logging.DEBUG'
2828
# default logging level is set to 'WARNING'
29-
def setup_logging(
30-
level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE_FORMAT
31-
):
29+
def setup_logging(level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE_FORMAT):
3230
logging.basicConfig(level=level, format=log_format, datefmt=date_format)
3331

3432

splunklib/ai/agent.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ async def _start_agent(self) -> AsyncGenerator[Self]:
183183
"internal error: _impl was not set to None after agent invocation"
184184
)
185185

186-
splunk_username = await asyncio.to_thread(
187-
lambda: _get_splunk_username(self._service)
188-
)
186+
splunk_username = await asyncio.to_thread(lambda: _get_splunk_username(self._service))
189187
_validate_agent_privileges(splunk_username)
190188

191189
self.logger.debug(f"Creating agent {self.name=}; {self.trace_id=}")
@@ -201,9 +199,7 @@ async def _start_agent(self) -> AsyncGenerator[Self]:
201199

202200
self._impl = None
203201

204-
async def _load_tools(
205-
self, stack: AsyncExitStack, splunk_username: str
206-
) -> list[Tool]:
202+
async def _load_tools(self, stack: AsyncExitStack, splunk_username: str) -> list[Tool]:
207203
tools: list[Tool] = []
208204
if not self.tool_settings.local and not self.tool_settings.remote:
209205
return tools
@@ -234,9 +230,7 @@ async def _load_tools(
234230
if self.tool_settings.remote:
235231
self.logger.debug("Probing MCP Server App availability")
236232
remote_session = await stack.enter_async_context(
237-
connect_remote_mcp(
238-
self._service, app_id, self.trace_id, splunk_username
239-
)
233+
connect_remote_mcp(self._service, app_id, self.trace_id, splunk_username)
240234
)
241235

242236
if remote_session:
@@ -252,9 +246,7 @@ async def _load_tools(
252246
allowlist = self.tool_settings.remote.allowlist
253247
remote_tools = [rt for rt in remote_tools if allowlist.is_allowed(rt)]
254248

255-
self.logger.debug(
256-
f"Loaded remote_tools={[t.name for t in remote_tools]}"
257-
)
249+
self.logger.debug(f"Loaded remote_tools={[t.name for t in remote_tools]}")
258250
tools.extend(remote_tools)
259251

260252
return tools
@@ -265,13 +257,9 @@ async def __aenter__(self) -> Self:
265257
self._agent_context_manager = self._start_agent()
266258
return await self._agent_context_manager.__aenter__()
267259

268-
async def __aexit__(
269-
self, exc_type: ..., exc_value: ..., traceback: ...
270-
) -> bool | None:
260+
async def __aexit__(self, exc_type: ..., exc_value: ..., traceback: ...) -> bool | None:
271261
assert self._agent_context_manager is not None
272-
result = await self._agent_context_manager.__aexit__(
273-
exc_type, exc_value, traceback
274-
)
262+
result = await self._agent_context_manager.__aexit__(exc_type, exc_value, traceback)
275263
self._agent_context_manager = None
276264
return result
277265

@@ -324,9 +312,7 @@ def _local_tools_path() -> tuple[str | None, str]:
324312
app_id, app_dir = locate_app()
325313
local_tools_path = build_local_tools_path(app_dir)
326314

327-
assert app_id is not None, (
328-
"_load_tools_from_mcp was mocked, but _testing_app_id not"
329-
)
315+
assert app_id is not None, "_load_tools_from_mcp was mocked, but _testing_app_id not"
330316

331317
if not os.path.exists(local_tools_path):
332318
local_tools_path = None

splunklib/ai/conversation_store.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
class ConversationStore(Protocol):
2222
async def get_messages(self, thread_id: str) -> Sequence[BaseMessage]: ...
2323

24-
async def store_messages(
25-
self, thread_id: str, messages: list[BaseMessage]
26-
) -> None: ...
24+
async def store_messages(self, thread_id: str, messages: list[BaseMessage]) -> None: ...
2725

2826

2927
class InMemoryStore(ConversationStore):

0 commit comments

Comments
 (0)