https://github.com/python/cpython/commit/4677e25714bae597149a6fdfd50083548b8fb400
commit: 4677e25714bae597149a6fdfd50083548b8fb400
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: JelleZijlstra <[email protected]>
date: 2026-06-24T03:27:00Z
summary:

[3.15] gh-150994: _colorize: modernize typing imports (GH-151018) (#152041)

gh-150994: _colorize: modernize typing imports (GH-151018)
(cherry picked from commit fcda96fbf399d069d11f7e874352ad03273cf0b7)

Co-authored-by: Jelle Zijlstra <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst
A Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst
M Lib/_colorize.py
M Lib/test/test__colorize.py

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"}
         )
 
 
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
index 000000000000000..c4a610c24806b0a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst
@@ -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
index 000000000000000..005a1d99b766dce
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst
@@ -0,0 +1 @@
+Make type annotations in the private ``_colorize`` module resolvable.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to