Defaults for kwonly arguments don't show in help
melsabagh opened this issue · 2 comments
melsabagh commented
Fire (v0.4.0, master) does not seem to show default values for keyword-only arguments. Consider the following example:
#!/usr/bin/env python3
import fire
def foo(*, bar=True):
print(bar)
if __name__ == '__main__':
fire.Fire(foo)
Save it as foo.py
and run python3 foo.py --help
.
Expected Output:
INFO: Showing help with the command 'foo.py -- --help'.
NAME
foo.py
SYNOPSIS
foo.py <flags>
FLAGS
--bar=BAR
Default: True
Actual Output:
INFO: Showing help with the command 'foo.py -- --help'.
NAME
foo.py
SYNOPSIS
foo.py <flags>
FLAGS
--bar=BAR
Looks like a one line change could fix this: change the return
statement here
Line 527 in 37c4305
return repr(spec.kwonlydefaults.get(flag, ''))
amrutharajashekar commented
Hi I would like to work on this issue.
Thanks!
dbieber commented
return repr(spec.kwonlydefaults.get(flag, ''))
Thanks for identifying the fix. Quick note - repr('') doesn't evaluate to '', so that one-liner is quite right, but it gets the idea across. Let's include this improvement in the next release 👍