Skip to content

Commit 4677e25

Browse files
[3.15] gh-150994: _colorize: modernize typing imports (GH-151018) (#152041)
gh-150994: _colorize: modernize typing imports (GH-151018) (cherry picked from commit fcda96f) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 415e218 commit 4677e25

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

Lib/_colorize.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44

55
from collections.abc import Callable, Iterator, Mapping
66
from dataclasses import dataclass, field, Field
7+
lazy from typing import IO, Literal, Self, ClassVar
78

89
COLORIZE = True
910

10-
11-
# types
12-
if False:
13-
from typing import IO, Literal, Self, ClassVar
14-
_theme: Theme
11+
_theme: Theme
12+
type BackgroundStyle = Literal["dark", "light"]
1513

1614

1715
class ANSIColors:
@@ -319,7 +317,7 @@ class LiveProfiler(ThemeSection):
319317
medal_bronze_fg: int = CursesColors.GREEN
320318

321319
# Background style: 'dark' or 'light'
322-
background_style: Literal["dark", "light"] = "dark"
320+
background_style: BackgroundStyle = "dark"
323321

324322

325323
LiveProfilerLight = LiveProfiler(

Lib/test/test__colorize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestImportTime(unittest.TestCase):
2828
@cpython_only
2929
def test_lazy_import(self):
3030
import_helper.ensure_lazy_imports(
31-
"_colorize", {"copy", "re", "inspect"}
31+
"_colorize", {"copy", "re", "inspect", "typing"}
3232
)
3333

3434

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make the type annotations in the private ``_colorize`` module resolvable.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make type annotations in the private ``_colorize`` module resolvable.

0 commit comments

Comments
 (0)