diff --git a/requirements-tests.txt b/requirements-tests.txt index cac6dbc83..cb157edd8 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -10,7 +10,7 @@ packaging==21.3 pycln==2.1.1 # must match .pre-commit-config.yaml pyyaml==6.0 pytype==2022.08.30; platform_system != "Windows" -termcolor +termcolor>=2 tomli==1.2.2 tomlkit==0.11.4 types-pyyaml diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index f589554eb..971bea07e 100644 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -18,22 +18,14 @@ import zipfile from collections.abc import Mapping from dataclasses import dataclass from pathlib import Path -from typing import TYPE_CHECKING, Any, TypeVar +from typing import Any, TypeVar import aiohttp import packaging.specifiers import packaging.version import tomli import tomlkit - -if TYPE_CHECKING: - - def colored(__str: str, __style: str) -> str: - ... - -else: - from termcolor import colored - +from termcolor import colored ActionLevelSelf = TypeVar("ActionLevelSelf", bound="ActionLevel") diff --git a/tests/utils.py b/tests/utils.py index e941afe36..e560acb34 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,28 +3,16 @@ import os from functools import cache from pathlib import Path -from typing import TYPE_CHECKING, NamedTuple +from typing import NamedTuple import tomli -# ==================================================================== -# Some simple hacks so we don't have to install types-termcolor in CI, -# and so that tests can be run locally without termcolor installed, -# if desired -# ==================================================================== +try: + from termcolor import colored as colored +except ImportError: -if TYPE_CHECKING: - - def colored(__str: str, __style: str) -> str: - ... - -else: - try: - from termcolor import colored - except ImportError: - - def colored(s: str, _: str) -> str: - return s + def colored(s: str, _: str) -> str: # type: ignore + return s def print_error(error: str, end: str = "\n", fix_path: tuple[str, str] = ("", "")) -> None: