Repository navigation
Re-expose supports_kitty_graphics as a lazy module attribute - #15461
Merged
Carreau merged 1 commit intoNov 2, 2026
Merged
Conversation
Commit b7a6320 (ipython#15424) dropped the import-time evaluation of supports_kitty_graphics to keep process-tree walks out of startup, which removed the name from the module namespace; downstream code such as sagemath still imports it. Resolve it on access through a PEP 562 module __getattr__ instead: `from IPython.core.kitty import supports_kitty_graphics` works again while startup stays free of the detection cost. Fixes ipython#15460 🤖 This contribution was drafted with AI assistance; the analysis, the change and the tests are described above so that they can be reviewed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15460
Problem
Commit b7a6320 (in #15424) replaced the import-time evaluation of
supports_kitty_graphicswith on-demand checks, which removed the name from theIPython.core.kittymodule namespace. Downstream code that imports it - e.g. sagemath'ssage/repl/interpreter.py- stopped working on 9.18.Fix
Add a PEP 562 module-level
__getattr__toIPython.core.kittythat resolvessupports_kitty_graphicson access by calling the existing private_supports_kitty_graphics():This keeps the startup-optimization intent of #15424 (no process-tree walk at import time) while restoring the public name; unknown attributes still raise
AttributeError.Tests
test_supports_kitty_graphics_public_alias- the attribute resolves on the module (red on main withAttributeError).test_supports_kitty_graphics_from_import-from IPython.core.kitty import supports_kitty_graphicsworks (red on main withImportError).test_kitty_module_getattr_rejects_unknown_names- unknown attributes keep raisingAttributeError.tests/test_kitty.py: 25 passed, 1 skipped.Note for CI:
ruff check(latest) reports two pre-existingPLW1510findings intests/test_kitty.py(subprocess.runwithout explicitcheck=False, lines 50/266, untouched by this PR) andruff format --checkflags the pre-existing multi-line emptyterminal_default_mime_renderersdict - all present on main, left untouched here.🤖 This contribution was drafted with AI assistance; the analysis, the change and the tests are described above so that they can be reviewed.