Skip to content

Add _name method to Trigger base class#595

Merged
gnachman merged 3 commits intognachman:masterfrom
mkusaka:fix/triggers-base-class-name
Mar 2, 2026
Merged

Add _name method to Trigger base class#595
gnachman merged 3 commits intognachman:masterfrom
mkusaka:fix/triggers-base-class-name

Conversation

@mkusaka
Copy link
Contributor

@mkusaka mkusaka commented Feb 28, 2026

Summary

Added a _name static method to the Trigger base class. Trigger.encode calls self._name() but the base class did not define it, causing AttributeError on unrecognized trigger types.

Background

  • All Trigger subclasses define @staticmethod _name() returning their class name, but the base class did not
  • decode_trigger() returns a bare Trigger instance for unrecognized trigger types (line 79), and calling .encode on it crashed

Example

from iterm2.triggers import decode_trigger

# Unrecognized trigger type returns a base Trigger instance
encoded = {
    "action": "SomeFutureTrigger",
    "regex": "test",
}
trigger = decode_trigger(encoded)
trigger.encode  # AttributeError: 'Trigger' object has no attribute '_name'

mkusaka and others added 3 commits March 1, 2026 04:48
Trigger.encode calls self._name() but the base class did not define it,
causing AttributeError on unrecognized trigger types returned by
decode_trigger.
Verify that:
- Trigger base class has _name attribute
- Trigger._name() returns "Trigger"
- Trigger.encode does not crash on bare Trigger instances
- Unrecognized trigger types can round-trip through decode/encode
@gnachman gnachman merged commit f024a97 into gnachman:master Mar 2, 2026
2 checks passed
@mkusaka mkusaka deleted the fix/triggers-base-class-name branch March 2, 2026 06:37
@mkusaka mkusaka mentioned this pull request Mar 5, 2026
2 tasks
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