MCPcopy Index your code
hub / github.com/ipython/ipython / _supports_kitty_graphics

Function _supports_kitty_graphics

IPython/core/kitty.py:7–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5from typing import Union
6
7def _supports_kitty_graphics() -> bool:
8 import platform
9
10 if platform.system() not in ("Darwin", "Linux"):
11 return False
12
13 isatty = getattr(sys.stdout, "isatty", None)
14 if not callable(isatty) or not isatty():
15 return False
16 # Hardcoding process names instead of using
17 # https://sw.kovidgoyal.net/kitty/graphics-protocol/#querying-support-and-available-transmission-mediums
18 # to avoid startup slowdown
19 supported_terminals = {
20 "ghostty",
21 "iTerm2",
22 "kitty",
23 "konsole",
24 "warp",
25 "wayst",
26 "wezterm-gui",
27 }
28 import psutil
29
30 try:
31 process = psutil.Process()
32 while process := process.parent():
33 if process.name() in supported_terminals:
34 return True
35 except (psutil.Error, OSError):
36 # Walking the process tree can fail when /proc is mounted with
37 # ``hidepid`` on shared multi-user systems (common on HPC clusters):
38 # ancestor processes owned by other users are inaccessible and psutil
39 # raises AccessDenied. Treat as "unsupported" rather than letting it
40 # abort the import of IPython.
41 return False
42 return False
43
44
45supports_kitty_graphics = _supports_kitty_graphics()

Callers 1

kitty.pyFile · 0.85

Calls 3

systemMethod · 0.80
parentMethod · 0.80
nameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…