]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-150994: _colorize: modernize typing imports (#151018)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Wed, 24 Jun 2026 02:58:00 +0000 (19:58 -0700)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 02:58:00 +0000 (19:58 -0700)
Lib/_colorize.py
Lib/test/test__colorize.py
Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst [new file with mode: 0644]
Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst [new file with mode: 0644]

index 5e0c0124e597b89b924452238288c4e6a13414a7..27eb7f13baca97163e88bfc86fa6242e880a7696 100644 (file)
@@ -4,14 +4,12 @@ import sys
 
 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(
index 48fa52bfd5672cb24ec76aa54b820169d7a0fc87..c7bc6914ac1bc442fbfc0a0c1d51a8ceaae478e3 100644 (file)
@@ -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"}
         )
 
 
diff --git a/Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst b/Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst
new file mode 100644 (file)
index 0000000..c4a610c
--- /dev/null
@@ -0,0 +1 @@
+Make the type annotations in the private ``_colorize`` module resolvable.
diff --git a/Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst b/Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst
new file mode 100644 (file)
index 0000000..005a1d9
--- /dev/null
@@ -0,0 +1 @@
+Make type annotations in the private ``_colorize`` module resolvable.