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,
)
| 496 | |
| 497 | |
| 498 | def 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 | |
| 522 | def set_theme(t: Theme) -> None: |
searching dependent graphs…