projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More cleanup.
[python_utils.git]
/
string_utils.py
diff --git
a/string_utils.py
b/string_utils.py
index d75c6ba1aca2c559ed4254d535747c54f4719bf5..4bec031738e989d10507992387e18aa47996da8e 100644
(file)
--- a/
string_utils.py
+++ b/
string_utils.py
@@
-40,7
+40,17
@@
import string
import unicodedata
import warnings
from itertools import zip_longest
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
from uuid import uuid4
import list_utils
@@
-1208,7
+1218,7
@@
def sprintf(*args, **kwargs) -> str:
return ret
return ret
-class SprintfStdout(
object
):
+class SprintfStdout(
contextlib.AbstractContextManager
):
"""
A context manager that captures outputs to stdout.
"""
A context manager that captures outputs to stdout.
@@
-1228,10
+1238,10
@@
class SprintfStdout(object):
self.recorder.__enter__()
return lambda: self.destination.getvalue()
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)
self.recorder.__exit__(*args)
self.destination.seek(0)
- return
None # don't suppress exceptions
+ return
False
def capitalize_first_letter(txt: str) -> str:
def capitalize_first_letter(txt: str) -> str: