Skip to content

Fix type annotations in triggers.py for mypy compliance#603

Merged
gnachman merged 1 commit intognachman:masterfrom
mkusaka:fix/triggers-mypy-errors
Mar 2, 2026
Merged

Fix type annotations in triggers.py for mypy compliance#603
gnachman merged 1 commit intognachman:masterfrom
mkusaka:fix/triggers-mypy-errors

Conversation

@mkusaka
Copy link
Contributor

@mkusaka mkusaka commented Mar 2, 2026

Summary

Fixes 8 mypy errors (6 distinct issues) in triggers.py:

  1. decode_trigger return type ([return-value]): Returns EventTrigger which is not a Trigger subclass. Changed return type to Union[Trigger, EventTrigger].

  2. BellTrigger._param return type ([return-value]): Typed -> None but returns "". Changed to -> str.

  3. BounceTrigger.Action forward references ([name-defined], 3 locations): 'iterm2.Trigger.BounceTrigger.Action' is not a valid name path. Changed to 'BounceTrigger.Action'.

  4. PasswordTrigger.user_name return type ([return-value]): __init__ accepts user_name: Optional[str] but property was typed -> str. Changed to -> Optional[str].

  5. CommandFinishedEventTrigger.deserialize local variable ([assignment]): exit_code_filter starts as ExitCodeFilter but can be assigned int. Added explicit type annotation Union[ExitCodeFilter, int].

  6. LongRunningCommandEventTrigger.__init__ dict type ([assignment]): event_params inferred as Dict[str, float] from {"threshold": threshold} but later assigned str value. Added explicit annotation Dict[str, Any].

- decode_trigger: return Union[Trigger, EventTrigger] since EventTrigger
  is not a Trigger subclass
- BellTrigger._param: fix return type None -> str
- BounceTrigger: fix forward references from
  'iterm2.Trigger.BounceTrigger.Action' to 'BounceTrigger.Action'
- PasswordTrigger.user_name: return Optional[str] to match __init__
- CommandFinishedEventTrigger.deserialize: annotate exit_code_filter
  local as Union[ExitCodeFilter, int]
- LongRunningCommandEventTrigger.__init__: annotate event_params as
  Dict[str, Any] to allow mixed value types
@gnachman gnachman merged commit 9b12249 into gnachman:master Mar 2, 2026
2 checks passed
@mkusaka mkusaka deleted the fix/triggers-mypy-errors branch March 3, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants