From fea5c472a849e2d7133bee54f7dc113d837bbea0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 6 Jun 2026 06:28:08 -0700 Subject: [PATCH] _colorize: modernize typing imports --- Lib/_colorize.py | 10 ++++------ Lib/test/test__colorize.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Lib/_colorize.py b/Lib/_colorize.py index 5e0c0124e597b89..27eb7f13baca971 100644 --- a/Lib/_colorize.py +++ b/Lib/_colorize.py @@ -4,14 +4,12 @@ from collections.abc import Callable, Iterator, Mapping from dataclasses import dataclass, field, Field +lazy from typing import IO, Literal, Self, ClassVar COLORIZE = True - -# types -if False: - from typing import IO, Literal, Self, ClassVar - _theme: Theme +_theme: Theme +type BackgroundStyle = Literal["dark", "light"] class ANSIColors: @@ -319,7 +317,7 @@ class LiveProfiler(ThemeSection): medal_bronze_fg: int = CursesColors.GREEN # Background style: 'dark' or 'light' - background_style: Literal["dark", "light"] = "dark" + background_style: BackgroundStyle = "dark" LiveProfilerLight = LiveProfiler( diff --git a/Lib/test/test__colorize.py b/Lib/test/test__colorize.py index 48fa52bfd5672cb..c7bc6914ac1bc44 100644 --- a/Lib/test/test__colorize.py +++ b/Lib/test/test__colorize.py @@ -28,7 +28,7 @@ class TestImportTime(unittest.TestCase): @cpython_only def test_lazy_import(self): import_helper.ensure_lazy_imports( - "_colorize", {"copy", "re", "inspect"} + "_colorize", {"copy", "re", "inspect", "typing"} )