diff options
| author | Scott Gasch <[email protected]> | 2022-02-08 20:21:02 -0800 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-02-08 20:21:02 -0800 |
| commit | 2f5b47c8b30d1b7d86443391332be2f3805cdafd (patch) | |
| tree | 181f08770989ed65f859d8c6772d1d71336c77c7 /text_utils.py | |
| parent | 4b04fd1d5a14c5c4c7e0985e5376b4e2f879ef06 (diff) | |
Cleanup more contextlib.AbstractContextManagers and Literal[False]s.
Diffstat (limited to 'text_utils.py')
| -rw-r--r-- | text_utils.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/text_utils.py b/text_utils.py index 4384a1e..7910990 100644 --- a/text_utils.py +++ b/text_utils.py @@ -3,11 +3,12 @@ """Utilities for dealing with "text".""" +import contextlib import logging import math import sys from collections import defaultdict -from typing import Dict, Generator, List, NamedTuple, Optional, Tuple +from typing import Dict, Generator, List, Literal, NamedTuple, Optional, Tuple from ansi import fg, reset @@ -261,7 +262,7 @@ def wrap_string(text: str, n: int) -> str: return out -class Indenter(object): +class Indenter(contextlib.AbstractContextManager): """ with Indenter(pad_count = 8) as i: i.print('test') @@ -289,10 +290,11 @@ class Indenter(object): self.level += 1 return self - def __exit__(self, exc_type, exc_value, exc_tb): + def __exit__(self, exc_type, exc_value, exc_tb) -> Literal[False]: self.level -= 1 if self.level < -1: self.level = -1 + return False def print(self, *arg, **kwargs): import string_utils |
