Skip to content

Fix bugs in Color.from_cocoa and from_legacy_trigger#598

Merged
gnachman merged 2 commits intognachman:masterfrom
mkusaka:fix/color-missing-dependency
Mar 2, 2026
Merged

Fix bugs in Color.from_cocoa and from_legacy_trigger#598
gnachman merged 2 commits intognachman:masterfrom
mkusaka:fix/color-missing-dependency

Conversation

@mkusaka
Copy link
Contributor

@mkusaka mkusaka commented Feb 28, 2026

Summary

Three bugs in color.py, all introduced in bda9aec when pyobjc was made optional:

  • MissingDependency is raised but never defined — added as a subclass of ImportError
  • int(str) passes the str type instead of the parameter s — fixed to int(s)
  • Return type annotation ('Color', 'Color') is invalid syntax for mypy — fixed to typing.Tuple[Optional[Color], Optional[Color]]

Examples

Color.from_cocoa raises NameError instead of a meaningful error when pyobjc is not installed:

from iterm2.color import Color

Color.from_cocoa("dGVzdA==")
# NameError: name 'MissingDependency' is not defined

Color.from_legacy_trigger always raises TypeError because int(str) passes the type object:

from iterm2.color import Color

Color.from_legacy_trigger("0")
# TypeError: int() argument must be a string, a bytes-like object or a real number, not 'type'

mkusaka added 2 commits March 1, 2026 06:09
…in color.py

- Define MissingDependency as a subclass of ImportError
- Fix int(str) to int(s) in from_legacy_trigger
- Fix return type annotation from ('Color', 'Color') to typing.Tuple
@gnachman gnachman merged commit 39dc92d into gnachman:master Mar 2, 2026
2 checks passed
@gnachman
Copy link
Owner

gnachman commented Mar 2, 2026

Thanks!

@mkusaka mkusaka deleted the fix/color-missing-dependency branch March 2, 2026 06:37
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