diff options
Diffstat (limited to 'src/snakeoil/strings.py')
-rw-r--r-- | src/snakeoil/strings.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/snakeoil/strings.py b/src/snakeoil/strings.py index 7d7b2a83..d0dc58ab 100644 --- a/src/snakeoil/strings.py +++ b/src/snakeoil/strings.py @@ -2,10 +2,10 @@ from .demandload import demand_compile_regexp -demand_compile_regexp('_whitespace_regex', r'^(?P<indent>\s+)') +demand_compile_regexp("_whitespace_regex", r"^(?P<indent>\s+)") -def pluralism(obj, none=None, singular='', plural='s'): +def pluralism(obj, none=None, singular="", plural="s"): """Return singular or plural suffix depending on object's length or value.""" # default to plural for empty objects, e.g. there are 0 repos if none is None: @@ -27,16 +27,16 @@ def pluralism(obj, none=None, singular='', plural='s'): def doc_dedent(s): """Support dedenting docstrings with initial line having no indentation.""" try: - lines = s.split('\n') + lines = s.split("\n") except AttributeError: - raise TypeError(f'{s!r} is not a string') + raise TypeError(f"{s!r} is not a string") if lines: # find first line with an indent if one exists for line in lines: if mo := _whitespace_regex.match(line): - indent = mo.group('indent') + indent = mo.group("indent") break else: - indent = '' + indent = "" len_i = len(indent) - return '\n'.join(x[len_i:] if x.startswith(indent) else x for x in lines) + return "\n".join(x[len_i:] if x.startswith(indent) else x for x in lines) |