mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-22 16:25:58 +00:00
fix: replace assert with runtime guard in Slack block_kit rich_text builder
assert statements are stripped when Python runs with -O flag. Replace the assert cur is not None in _rich_text_list_block() with an explicit if/continue guard. The assert is technically unreachable (first loop iteration always sets cur), but using assert for invariant checking in production code is fragile under optimization.
This commit is contained in:
parent
d91a143977
commit
8fc0c086f5
1 changed files with 5 additions and 1 deletions
|
|
@ -227,7 +227,11 @@ def _list_block(items: List[Tuple[int, bool, str]]) -> Block:
|
|||
}
|
||||
elements.append(cur)
|
||||
cur_key = key
|
||||
assert cur is not None
|
||||
if cur is None:
|
||||
# Defensive: should never happen (first iteration always enters
|
||||
# the ``if key != cur_key`` block above), but guard explicitly
|
||||
# so ``python -O`` doesn't silently drop the check.
|
||||
continue
|
||||
cur["elements"].append(
|
||||
{"type": "rich_text_section", "elements": _nonempty_elements(_inline_elements(text))}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue