summaryrefslogtreecommitdiff
path: root/string_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'string_utils.py')
-rw-r--r--string_utils.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/string_utils.py b/string_utils.py
index d75c6ba..adfb149 100644
--- a/string_utils.py
+++ b/string_utils.py
@@ -40,7 +40,7 @@ import string
import unicodedata
import warnings
from itertools import zip_longest
-from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple
+from typing import Any, Callable, Dict, Iterable, List, Literal, Optional, Sequence, Tuple
from uuid import uuid4
import list_utils
@@ -1208,7 +1208,7 @@ def sprintf(*args, **kwargs) -> str:
return ret
-class SprintfStdout(object):
+class SprintfStdout(contextlib.AbstractContextManager):
"""
A context manager that captures outputs to stdout.
@@ -1228,10 +1228,10 @@ class SprintfStdout(object):
self.recorder.__enter__()
return lambda: self.destination.getvalue()
- def __exit__(self, *args) -> None:
+ def __exit__(self, *args) -> Literal[False]:
self.recorder.__exit__(*args)
self.destination.seek(0)
- return None # don't suppress exceptions
+ return False
def capitalize_first_letter(txt: str) -> str: