Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] typed arguments #300

Open
Nov1kov opened this issue Dec 4, 2020 · 3 comments · May be fixed by #350
Open

[FEATURE REQUEST] typed arguments #300

Nov1kov opened this issue Dec 4, 2020 · 3 comments · May be fixed by #350

Comments

@Nov1kov
Copy link

Nov1kov commented Dec 4, 2020

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.

@UrielMaD
Copy link

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

@Nov1kov
Copy link
Author

Nov1kov commented Dec 23, 2020

@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:

  1. Unexpected types (e.g. def method(arg: MyCustomObject):
  2. raise Exceptions for unexpected types.

loynoir added a commit to loynoir/python-fire that referenced this issue Feb 15, 2021
@keanpantraw keanpantraw linked a pull request Aug 20, 2021 that will close this issue
@indigoviolet
Copy link

indigoviolet commented Sep 19, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants