Reviewer · Code Style
Type annotation hygiene
Keep type annotations and imports accurate, minimal, and statically checkable so tooling (and future readers) can trust them. - Remove imports that become unused after a refactor (e.g. dropping a parameter typed `Dict[str, str]` may leave `Dict` unused in that function, even if other functions in the file still need it — verify with your linter rather than...
Keep type annotations and imports accurate, minimal, and statically checkable so tooling (and future readers) can trust them.
- Remove imports that become unused after a refactor (e.g. dropping a parameter typed
Dict[str, str]may leaveDictunused in that function, even if other functions in the file still need it — verify with your linter rather than assuming). - When an attribute is only ever created inside a helper method reached indirectly from
__init__(e.g. viainitialize_swarm()->init_swarm()), add a bare class-level annotation so the contract is documented and type checkers stop flagging every read as undefined:
class HierarchicalSwarm:
conversation: Conversation
_delivered: Dict[str, int]
This creates no runtime attribute and keeps attribute creation in the helper, but makes the type explicit for readers and tools.
- Avoid constructing
Literal[...]from a function call (e.g.Literal[get_reasoning_efforts()]) — this is not a valid literal and is unusable by static checkers even though it works at runtime. Instead, define the literal type as the single source of truth and derive any runtime collection from it:
ReasoningEffort = Literal[
"none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max",
]
REASONING_EFFORTS: Tuple[str, ...] = get_args(ReasoningEffort)
Then annotate parameters with the alias (reasoning_effort: ReasoningEffort = "medium") instead of the raw tuple, keeping the signature checkable while preserving identical accepted values.
Applying these practices keeps signatures and class contracts readable and verifiable by static analysis, preventing stale imports and unchecked annotations from accumulating.</description>