Skip to content

Commit 9249d4e

Browse files
author
Carlos-Projects
committed
chore: apply ruff format
1 parent 2f194a9 commit 9249d4e

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

mcpscope/webhooks.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import asyncio
4+
35
import httpx
46
from mcpscope.models.finding import Finding, Severity
57

@@ -110,18 +112,21 @@ def notify_scan_imported(
110112
}
111113
)
112114

113-
import asyncio
115+
if webhooks or slack_url:
116+
117+
async def _notify():
118+
if webhooks:
119+
payload = {
120+
"event": "scan_imported",
121+
"summary": summary,
122+
"alerts": alerts,
123+
}
124+
await fire_webhooks(webhooks, "scan_imported", payload)
125+
if slack_url:
126+
await fire_slack(slack_url, scan_id, scanner, summary, alerts)
114127

115-
if webhooks:
116-
payload = {"event": "scan_imported", "summary": summary, "alerts": alerts}
117-
try:
118-
asyncio.create_task(fire_webhooks(webhooks, "scan_imported", payload))
119-
except RuntimeError:
120-
pass
121-
if slack_url:
122128
try:
123-
asyncio.create_task(
124-
fire_slack(slack_url, scan_id, scanner, summary, alerts)
125-
)
129+
task = asyncio.ensure_future(_notify())
130+
task.add_done_callback(lambda t: t.exception())
126131
except RuntimeError:
127132
pass

0 commit comments

Comments
 (0)