From 95182f0edbdb8742b17d59d4ccb3ce5cc3029047 Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Tue, 26 May 2026 16:37:16 +0000 Subject: [PATCH 1/3] fix colorful handle dynamic type --- stubs/colorful/colorful/__init__.pyi | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/stubs/colorful/colorful/__init__.pyi b/stubs/colorful/colorful/__init__.pyi index e69de29bb2d1..9ed36f7b52fc 100644 --- a/stubs/colorful/colorful/__init__.pyi +++ b/stubs/colorful/colorful/__init__.pyi @@ -0,0 +1,59 @@ +from _typeshed import SupportsWrite +from builtins import str as _str +from collections.abc import ContextManager +from typing import Final +from typing_extensions import LiteralString + +from .core import Colorful, ColorfulString, _ColorModeType, _PaletteType + +__version__: Final[_str] + +NO_COLORS: Final[int] +ANSI_8_COLORS: Final[int] +ANSI_16_COLORS: Final[int] +ANSI_256_COLORS: Final[int] +TRUE_COLORS: Final[int] +COLORNAMES_COLORS: Final[_str] + +close_fg_color: Final[_str] +close_bg_color: Final[_str] +no_bold: Final[_str] +no_dimmed: Final[_str] +no_italic: Final[_str] +no_underlined: Final[_str] +no_blinkslow: Final[_str] +no_blinkrapid: Final[_str] +no_inversed: Final[_str] +no_concealed: Final[_str] +no_struckthrough: Final[_str] + +colormode: _ColorModeType +colorpalette: _str | _PaletteType | None + +def setup( + colormode: _ColorModeType | None = None, colorpalette: _str | _PaletteType | None = None, extend_colors: bool = False +) -> None: ... +def disable() -> None: ... +def use_8_ansi_colors() -> None: ... +def use_16_ansi_colors() -> None: ... +def use_256_ansi_colors() -> None: ... +def use_true_colors() -> None: ... +def use_palette(colorpalette: _str | _PaletteType) -> None: ... +def update_palette(colorpalette: _str | _PaletteType) -> None: ... +def use_style(style_name: _str) -> None: ... +def format(string: _str, *args: LiteralString, **kwargs: LiteralString) -> _str: ... +def str(string: _str) -> ColorfulString: ... +def print( + *objects: object, sep: _str = " ", end: _str = "\n", file: SupportsWrite[_str] | None = None, flush: bool = False +) -> None: ... +def with_setup( + colormode: _ColorModeType | None = None, colorpalette: _str | _PaletteType | None = None, extend_colors: bool = False +) -> ContextManager[Colorful]: ... +def with_8_ansi_colors() -> ContextManager[Colorful]: ... +def with_16_ansi_colors() -> ContextManager[Colorful]: ... +def with_256_ansi_colors() -> ContextManager[Colorful]: ... +def with_true_colors() -> ContextManager[Colorful]: ... +def with_palette(colorpalette: _str | _PaletteType) -> ContextManager[Colorful]: ... +def with_updated_palette(colorpalette: _str | _PaletteType) -> ContextManager[Colorful]: ... +def with_style(style_name: _str) -> ContextManager[Colorful]: ... +def __getattr__(name: _str) -> Colorful.ColorfulStyle: ... From b8631fe752ce4432e3922e90eaacceca97e3c29f Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Tue, 26 May 2026 17:05:57 +0000 Subject: [PATCH 2/3] fix mypy error --- stubs/colorful/colorful/__init__.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stubs/colorful/colorful/__init__.pyi b/stubs/colorful/colorful/__init__.pyi index 9ed36f7b52fc..7beec3f0535b 100644 --- a/stubs/colorful/colorful/__init__.pyi +++ b/stubs/colorful/colorful/__init__.pyi @@ -1,7 +1,6 @@ from _typeshed import SupportsWrite from builtins import str as _str -from collections.abc import ContextManager -from typing import Final +from typing import ContextManager, Final from typing_extensions import LiteralString from .core import Colorful, ColorfulString, _ColorModeType, _PaletteType From 63a6530fcc51375a7a8b0a16680ac6924570d1ef Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Tue, 26 May 2026 17:17:51 +0000 Subject: [PATCH 3/3] fix mypy error --- stubs/colorful/colorful/__init__.pyi | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/stubs/colorful/colorful/__init__.pyi b/stubs/colorful/colorful/__init__.pyi index 7beec3f0535b..858e29720a73 100644 --- a/stubs/colorful/colorful/__init__.pyi +++ b/stubs/colorful/colorful/__init__.pyi @@ -1,6 +1,7 @@ from _typeshed import SupportsWrite from builtins import str as _str -from typing import ContextManager, Final +from contextlib import AbstractContextManager +from typing import Final from typing_extensions import LiteralString from .core import Colorful, ColorfulString, _ColorModeType, _PaletteType @@ -47,12 +48,12 @@ def print( ) -> None: ... def with_setup( colormode: _ColorModeType | None = None, colorpalette: _str | _PaletteType | None = None, extend_colors: bool = False -) -> ContextManager[Colorful]: ... -def with_8_ansi_colors() -> ContextManager[Colorful]: ... -def with_16_ansi_colors() -> ContextManager[Colorful]: ... -def with_256_ansi_colors() -> ContextManager[Colorful]: ... -def with_true_colors() -> ContextManager[Colorful]: ... -def with_palette(colorpalette: _str | _PaletteType) -> ContextManager[Colorful]: ... -def with_updated_palette(colorpalette: _str | _PaletteType) -> ContextManager[Colorful]: ... -def with_style(style_name: _str) -> ContextManager[Colorful]: ... +) -> AbstractContextManager[Colorful]: ... +def with_8_ansi_colors() -> AbstractContextManager[Colorful]: ... +def with_16_ansi_colors() -> AbstractContextManager[Colorful]: ... +def with_256_ansi_colors() -> AbstractContextManager[Colorful]: ... +def with_true_colors() -> AbstractContextManager[Colorful]: ... +def with_palette(colorpalette: _str | _PaletteType) -> AbstractContextManager[Colorful]: ... +def with_updated_palette(colorpalette: _str | _PaletteType) -> AbstractContextManager[Colorful]: ... +def with_style(style_name: _str) -> AbstractContextManager[Colorful]: ... def __getattr__(name: _str) -> Colorful.ColorfulStyle: ...