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

unexpected behavior with duplicate value for the same argument #25

Closed
the-realtom opened this issue Mar 18, 2017 · 2 comments
Closed

unexpected behavior with duplicate value for the same argument #25

the-realtom opened this issue Mar 18, 2017 · 2 comments

Comments

@the-realtom
Copy link

This is the code I'm running:

import fire

def test_duplicates(apples, paddles, oranges='10'):
    print('There are {} apples'.format(apples))
    print('There are {} paddles'.format(paddles))
    print('There are {} oranges'.format(oranges))

if __name__ == '__main__':
    fire.Fire(test_duplicates)

I am running python3 test.py 110 67 --apples=99 and producing the following result:

There are 99 apples
There are 110 paddles
There are 67 oranges

I see how Fire is evaluating the input, but if I'm not mistaken a positional and keyword argument collision should throw an error of some sort. I haven't looked under the hood yet but does this need a fix or am I using the command line wrong?

@dbieber
Copy link
Member

dbieber commented Mar 23, 2017

This is an interesting case. How did you come upon it?

As a user of this Fire CLI, if I write python3 test.py 110 67 --apples=99, then I certainly intend for apples to be 99, but it's unclear whether I want paddles and oranges to be 110 and 67, or whether I am trying to set apples yet again, in which case an error would be appropriate. I don't see a compelling reason for preferring the error over the more forgiving interpretation. We currently take the more forgiving approach.

What do you think?

@dbieber
Copy link
Member

dbieber commented Jul 26, 2019

Closing, feel free to reopen if you want to continue the discussion.

@dbieber dbieber closed this as completed Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants