MCPcopy Index your code
hub / github.com/python/cpython / get_theme

Function get_theme

Lib/_colorize.py:498–519  ·  view source on GitHub ↗

Returns the currently set theme, potentially in a zero-color variant. In cases where colorizing is not possible (see `can_colorize`), the returned theme contains all empty strings in all color definitions. See `Theme.no_colors()` for more information. It is recommended not to cache

(
    *,
    tty_file: IO[str] | IO[bytes] | None = None,
    force_color: bool = False,
    force_no_color: bool = False,
)

Source from the content-addressed store, hash-verified

496
497
498def get_theme(
499 *,
500 tty_file: IO[str] | IO[bytes] | None = None,
501 force_color: bool = False,
502 force_no_color: bool = False,
503) -> Theme:
504 """Returns the currently set theme, potentially in a zero-color variant.
505
506 In cases where colorizing is not possible (see `can_colorize`), the returned
507 theme contains all empty strings in all color definitions.
508 See `Theme.no_colors()` for more information.
509
510 It is recommended not to cache the result of this function for extended
511 periods of time because the user might influence theme selection by
512 the interactive shell, a debugger, or application-specific code. The
513 environment (including environment variable state and console configuration
514 on Windows) can also change in the course of the application life cycle.
515 """
516 if force_color or (not force_no_color and
517 can_colorize(file=tty_file)):
518 return _theme
519 return theme_no_color
520
521
522def set_theme(t: Theme) -> None:

Callers 13

_set_colorMethod · 0.90
_get_themeMethod · 0.90
unified_diffFunction · 0.90
runMethod · 0.90
runsourceMethod · 0.90
mainFunction · 0.90
__init__Method · 0.90
runMethod · 0.90
test_colorsMethod · 0.90
__init__Method · 0.90

Calls 1

can_colorizeFunction · 0.70

Tested by 3

test_colorsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…