Hi friends! Thanks as always for this amazing library; it's really made building CLIs in Python a breeze.
One thing I've noticed recently: when Fire-ing a function with an argument of type Optional[int], the help text for that argument has a bit of extraneous noise and gets cut off in such a way that we never see the int portion. Exempli gratia:
#!/usr/bin/env python
from typing import Optional
from fire import Fire
def main(n: Optional[int] = None):
n = 5 if n is None else n
print(f"You chose {n}.")
if __name__ == "__main__":
Fire(main)
Running
When I run ./test.py --help, I receive the following help message:
Perhaps it's happening because Optional[T] is equivalent to Union[T, None], but I find the type annotation's abbreviationOptional[typing.Unio...] in the help text a little wanting; ideally I'd prefer something like Optional[int] there. Granted, if this weren't a contrived, simplified example, I'd include a docstring that described the optional integer argument and not expect fire to take care of everything for me! But it'd be nice if we could see the type parameter inside that Optional.
Hi friends! Thanks as always for this amazing library; it's really made building CLIs in Python a breeze.
One thing I've noticed recently: when
Fire
-ing a function with an argument of typeOptional[int]
, the help text for that argument has a bit of extraneous noise and gets cut off in such a way that we never see theint
portion. Exempli gratia:Environment
Script
Running
When I run
./test.py --help
, I receive the following help message:Desiderata
Perhaps it's happening because
Optional[T]
is equivalent toUnion[T, None]
, but I find the type annotation's abbreviationOptional[typing.Unio...]
in the help text a little wanting; ideally I'd prefer something likeOptional[int]
there. Granted, if this weren't a contrived, simplified example, I'd include a docstring that described the optional integer argument and not expectfire
to take care of everything for me! But it'd be nice if we could see the type parameter inside thatOptional
.Thanks again!