mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix: resolve not-subscriptable ty diagnostics across codebase
Add TypedDicts for DEFAULT_CONFIG, CLI state dicts (_ModelPickerState, _ApprovalState, _ClarifyState), and OPTIONAL_ENV_VARS so ty can resolve nested dict subscripts. Guard Optional returns before subscripting (toolsets, cron/scheduler, delegate_tool), coerce str|None to str before slicing (gateway/run, run_agent), split ternary for isinstance narrowing (wecom), and suppress discord interaction.data access with ty: ignore.
This commit is contained in:
parent
72e7c0ce34
commit
fb6d37495b
9 changed files with 405 additions and 25 deletions
|
|
@ -3599,7 +3599,7 @@ if DISCORD_AVAILABLE:
|
|||
)
|
||||
return
|
||||
|
||||
provider_slug = interaction.data["values"][0]
|
||||
provider_slug = interaction.data["values"][0] # ty: ignore[not-subscriptable]
|
||||
self._selected_provider = provider_slug
|
||||
provider = next(
|
||||
(p for p in self.providers if p["slug"] == provider_slug), None
|
||||
|
|
@ -3634,7 +3634,7 @@ if DISCORD_AVAILABLE:
|
|||
return
|
||||
|
||||
self.resolved = True
|
||||
model_id = interaction.data["values"][0]
|
||||
model_id = interaction.data["values"][0] # ty: ignore[not-subscriptable]
|
||||
|
||||
try:
|
||||
result_text = await self.on_model_selected(
|
||||
|
|
|
|||
|
|
@ -698,7 +698,8 @@ class WeComAdapter(BasePlatformAdapter):
|
|||
elif isinstance(appmsg.get("image"), dict):
|
||||
refs.append(("image", appmsg["image"]))
|
||||
|
||||
quote = body.get("quote") if isinstance(body.get("quote"), dict) else {}
|
||||
raw_quote = body.get("quote")
|
||||
quote = raw_quote if isinstance(raw_quote, dict) else {}
|
||||
quote_type = str(quote.get("msgtype") or "").lower()
|
||||
if quote_type == "image" and isinstance(quote.get("image"), dict):
|
||||
refs.append(("image", quote["image"]))
|
||||
|
|
|
|||
|
|
@ -3886,7 +3886,7 @@ class GatewayRunner:
|
|||
message_text = f"{context_note}\n\n{message_text}"
|
||||
|
||||
if getattr(event, "reply_to_text", None) and event.reply_to_message_id:
|
||||
reply_snippet = event.reply_to_text[:500]
|
||||
reply_snippet = str(event.reply_to_text)[:500]
|
||||
found_in_history = any(
|
||||
reply_snippet[:200] in (msg.get("content") or "")
|
||||
for msg in history
|
||||
|
|
@ -10449,7 +10449,7 @@ class GatewayRunner:
|
|||
pending = None
|
||||
|
||||
if pending_event or pending:
|
||||
logger.debug("Processing pending message: '%s...'", pending[:40])
|
||||
logger.debug("Processing pending message: '%s...'", (pending or "")[:40])
|
||||
|
||||
# Clear the adapter's interrupt event so the next _run_agent call
|
||||
# doesn't immediately re-trigger the interrupt before the new agent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue