Skip to content

Commit 2e44937

Browse files
hanselhanselclaude
andcommitted
fix: resolve mypy errors in auditor gather and batch renderer
Split 9-arg asyncio.gather into two calls to stay within mypy's overload limits. Fix semantic_html lambda type and batch table add_row. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5660963 commit 2e44937

3 files changed

Lines changed: 36 additions & 17 deletions

File tree

src/context_cli/core/auditor.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,18 @@ async def audit_url(
219219
x402_task = check_x402(url, client)
220220
nlweb_task = check_nlweb(url, client)
221221

222+
# Run all checks concurrently — split into two gathers to stay
223+
# within mypy's asyncio.gather overload limits (max ~6 args).
224+
# Tasks from the second gather are already scheduled by the event
225+
# loop while the first gather is running.
226+
robots_result, llms_txt, cu_result, crawl_result = await asyncio.gather(
227+
robots_task, llms_task, content_usage_task, crawl_task,
228+
return_exceptions=True,
229+
)
222230
(
223-
robots_result, llms_txt, cu_result, crawl_result,
224231
agents_md_result, md_accept_result, mcp_result,
225232
x402_result, nlweb_result,
226233
) = await asyncio.gather(
227-
robots_task, llms_task, content_usage_task, crawl_task,
228234
agents_md_task, markdown_accept_task, mcp_endpoint_task,
229235
x402_task, nlweb_task,
230236
return_exceptions=True,
@@ -392,12 +398,14 @@ async def _audit_site_inner(
392398
x402_task = check_x402(url, client)
393399
nlweb_task = check_nlweb(url, client)
394400

401+
robots_result, llms_txt, cu_result, seed_crawl = await asyncio.gather(
402+
robots_task, llms_task, content_usage_task, crawl_task,
403+
return_exceptions=True,
404+
)
395405
(
396-
robots_result, llms_txt, cu_result, seed_crawl,
397406
agents_md_result, md_accept_result, mcp_result,
398407
x402_result, nlweb_result,
399408
) = await asyncio.gather(
400-
robots_task, llms_task, content_usage_task, crawl_task,
401409
agents_md_task, markdown_accept_task, mcp_endpoint_task,
402410
x402_task, nlweb_task,
403411
return_exceptions=True,

src/context_cli/core/checks/semantic_html.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ def check_semantic_html(html: str) -> SemanticHtmlReport:
3131
has_footer = soup.find("footer") is not None
3232
has_nav = soup.find("nav") is not None
3333

34-
aria_landmarks = len(
35-
soup.find_all(attrs={"role": lambda v: v and v.lower() in ARIA_LANDMARK_ROLES})
36-
)
34+
def _is_aria_landmark(v: str | None) -> bool:
35+
return bool(v and v.lower() in ARIA_LANDMARK_ROLES)
36+
37+
aria_landmarks = len(soup.find_all(attrs={"role": _is_aria_landmark}))
3738

3839
score = 0.0
3940
if has_main or has_article:

src/context_cli/formatters/rich_output.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,32 @@ def render_batch_rich(
233233

234234
for report in batch_report.reports:
235235
color = overall_color(report.overall_score)
236-
row = [
237-
report.url,
238-
Text(f"{report.overall_score}", style=color),
239-
f"{report.robots.score}",
240-
f"{report.llms_txt.score}",
241-
f"{report.schema_org.score}",
242-
f"{report.content.score}",
243-
]
236+
ar_score = ""
244237
if has_agent:
245238
ar_score = (
246239
f"{report.agent_readiness.score}"
247240
if report.agent_readiness
248241
else "-"
249242
)
250-
row.append(ar_score)
251-
table.add_row(*row)
243+
if has_agent:
244+
table.add_row(
245+
report.url,
246+
Text(f"{report.overall_score}", style=color),
247+
f"{report.robots.score}",
248+
f"{report.llms_txt.score}",
249+
f"{report.schema_org.score}",
250+
f"{report.content.score}",
251+
ar_score,
252+
)
253+
else:
254+
table.add_row(
255+
report.url,
256+
Text(f"{report.overall_score}", style=color),
257+
f"{report.robots.score}",
258+
f"{report.llms_txt.score}",
259+
f"{report.schema_org.score}",
260+
f"{report.content.score}",
261+
)
252262

253263
console.print(table)
254264

0 commit comments

Comments
 (0)