X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=ansi.py;h=6897291ba252f91c866b967cd18e0aa13f0f151d;hb=a4bf4d05230474ad14243d67ac7f8c938f670e58;hp=5fde4af56c9ef18254cd562ca19b10d853597e93;hpb=36fea7f15ed17150691b5b3ead75450e575229ef;p=python_utils.git diff --git a/ansi.py b/ansi.py index 5fde4af..6897291 100755 --- a/ansi.py +++ b/ansi.py @@ -1773,9 +1773,7 @@ def fg( green = 0 if blue is None: blue = 0 - if ( - is_16color(red) and is_16color(green) and is_16color(blue) - ) or force_16color: + if (is_16color(red) and is_16color(green) and is_16color(blue)) or force_16color: logger.debug("Using 16-color strategy") return fg_16color(red, green, blue) if ( @@ -1878,9 +1876,7 @@ def bg( green = 0 if blue is None: blue = 0 - if ( - is_16color(red) and is_16color(green) and is_16color(blue) - ) or force_16color: + if (is_16color(red) and is_16color(green) and is_16color(blue)) or force_16color: logger.debug("Using 16-color strategy") return bg_16color(red, green, blue) if ( @@ -1894,19 +1890,19 @@ def bg( class StdoutInterceptor(io.TextIOBase): def __init__(self): - self.saved_stdout: Optional[io.TextIOBase] = None + self.saved_stdout: io.TextIO = None self.buf = '' @abstractmethod def write(self, s: str): pass - def __enter__(self) -> None: + def __enter__(self): self.saved_stdout = sys.stdout sys.stdout = self - return None + return self - def __exit__(self, *args) -> bool: + def __exit__(self, *args) -> Optional[bool]: sys.stdout = self.saved_stdout print(self.buf) return None