mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
A more accurate termcolor.colored fallback (#9435)
This commit is contained in:
@@ -10,13 +10,21 @@ import venv
|
||||
from collections.abc import Mapping
|
||||
from functools import cache
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple
|
||||
from typing import Iterable, NamedTuple
|
||||
from typing_extensions import Annotated
|
||||
|
||||
import pathspec # type: ignore[import]
|
||||
import tomli
|
||||
from packaging.requirements import Requirement
|
||||
|
||||
try:
|
||||
from termcolor import colored as colored
|
||||
except ImportError:
|
||||
|
||||
def colored(text: str, color: str | None = None, on_color: str | None = None, attrs: Iterable[str] | None = None) -> str:
|
||||
return text
|
||||
|
||||
|
||||
# Used to install system-wide packages for different OS types:
|
||||
METADATA_MAPPING = {"linux": "apt_dependencies", "darwin": "brew_dependencies", "win32": "choco_dependencies"}
|
||||
|
||||
@@ -25,14 +33,6 @@ def strip_comments(text: str) -> str:
|
||||
return text.split("#")[0].strip()
|
||||
|
||||
|
||||
try:
|
||||
from termcolor import colored as colored
|
||||
except ImportError:
|
||||
|
||||
def colored(s: str, _: str) -> str: # type: ignore[misc]
|
||||
return s
|
||||
|
||||
|
||||
def print_error(error: str, end: str = "\n", fix_path: tuple[str, str] = ("", "")) -> None:
|
||||
error_split = error.split("\n")
|
||||
old, new = fix_path
|
||||
|
||||
Reference in New Issue
Block a user