Skip to content

Commit

Permalink
Refactor type hints to use built-in types for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Tsuyoshi Hombashi <[email protected]>
  • Loading branch information
thombashi committed Dec 29, 2024
1 parent b6c250f commit e714ee0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os.path
import re
from typing import Dict, Type

import setuptools

Expand All @@ -10,10 +9,10 @@
REQUIREMENT_DIR = "requirements"
ENCODING = "utf8"

pkg_info: Dict[str, str] = {}
pkg_info: dict[str, str] = {}


def get_release_command_class() -> Dict[str, Type[setuptools.Command]]:
def get_release_command_class() -> dict[str, type[setuptools.Command]]:
try:
from releasecmd import ReleaseCommand
except ImportError:
Expand Down
9 changes: 5 additions & 4 deletions tcolorpy/_truecolor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import re
from collections import namedtuple
from collections.abc import Sequence
from colorsys import rgb_to_hsv
from enum import Enum
from typing import Any, List, Optional, Sequence, Tuple, Type, Union, cast # noqa
from typing import Any, Optional, Union

from ._const import CSI, RESET, AnsiBGColor, AnsiFGColor, AnsiStyle


RGBTuple = Tuple[int, int, int]
RGBTuple = tuple[int, int, int]

HSV = namedtuple("HSV", "hue saturation value")

Expand Down Expand Up @@ -143,7 +144,7 @@ def calc_complementary(self) -> "Color":
return Color((n - self.red, n - self.green, n - self.blue))


def _normalize_enum(value: Any, enum_class: Type[Enum]) -> Any:
def _normalize_enum(value: Any, enum_class: type[Enum]) -> Any:
if isinstance(value, enum_class):
return value

Expand Down Expand Up @@ -238,7 +239,7 @@ def tcolor(
ansi_fg_color = _make_ansi_fg_truecolor(color)
ansi_bg_color = _make_ansi_bg_truecolor(bg_color)

ansi_styles: List[str] = []
ansi_styles: list[str] = []
if styles:
ansi_styles = [_to_ansi_style(style) for style in styles]

Expand Down

0 comments on commit e714ee0

Please sign in to comment.