Skip to content

Commit 9e6da34

Browse files
committed
Fixed minor bug in argreparse
1 parent d6d3418 commit 9e6da34

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/tinyscript/argreparse.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,13 @@ def __init__(self, *args, **kwargs):
368368
if v:
369369
d += " (" + v + ")"
370370
try:
371-
l = max(list(map(lambda x: len(txt2italic(x.strip('_'))),
372-
[bd for bd in BASE_DUNDERS if gd.get(bd) is not None])))
371+
l = max(len(txt2italic(bd.strip('_'))) for bd in BASE_DUNDERS if gd.get(bd) is not None)
372+
l2 = max(len(bd.strip('_')) for bd in BASE_DUNDERS if gd.get(bd) is not None)
373373
except ValueError:
374-
l = 0
374+
l = l2 = 0
375375
for k in BASE_DUNDERS:
376-
m = gd.get(k)
377-
if m:
376+
par = True
377+
if m := gd.get(k):
378378
if k == '__copyright__':
379379
if not isinstance(m, tuple):
380380
m = (m, )
@@ -399,13 +399,14 @@ def __init__(self, *args, **kwargs):
399399
reason = contributor.get('reason')
400400
if reason:
401401
s += " - " + str(reason)
402-
m += ["", "\n" + (l + 2) * " "][i > 0] + s
402+
m += ["", "\n" + (l2 + 2) * " "][i > 0] + s
403+
par = False
403404
meta = ("{: <%d}: {}" % l).format(txt2italic(k.strip('_').capitalize()), m)
404405
if k == '__author__':
405406
e = gd.get('__email__')
406407
if e:
407408
meta += " ({})".format(txt2email(e))
408-
d += ["\n\n", "\n"][self._docfmt is None] + txt2paragraph(meta)
409+
d += ["\n\n", "\n"][self._docfmt is None] + (txt2paragraph(meta) if par else meta)
409410
doc = txt2blockquote(gd.get('__doc__') or "")
410411
if doc:
411412
d += "\n\n" + doc

0 commit comments

Comments
 (0)