python-fire
python-fire copied to clipboard
[FEATURE REQUEST] typed arguments
If I write a typed variable argument, I am expecting an argument of a specific type. Example:
import fire
def test(some_str: str):
print(some_str)
if __name__ == "__main__":
fire.Fire()
Real result:
python test.py test 7.30
7.3
Expected Result:
python test.py test 7.30
7.30
So this feature will not break argument parsing. The typed argument should be enough to detect the real type.
Hello @Nov1kov, I was wondering if you want to add typed args to the whole codebase or there are some priority files? either way, I would like to take this issue
@UrielMaD Hello! Sorry for the late answer. I don't inspect the codebase yet. I'll be happy If you want to make this feature! 👍
I guess the feature is quite huge. We should define:
- Unexpected types (e.g. def method(arg: MyCustomObject):
- raise Exceptions for unexpected types.
@dbieber, do you think this behavior (casting command line argument values based on the function signature) is a good idea? If so, I'd like to work with you to define the feature and push through one of #350 or #320 or a variation of those.