google / python-fire

Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
Other
26.86k stars 1.44k forks source link

Simple string argument is Converted to integer because input only contains numeric data #453

Open kanaryayi opened 1 year ago

kanaryayi commented 1 year ago

A simple argument is automatically converted to integer because the input only has numeric data in a string. I wondered if it is a wanted feature. Thank you

Python3 version = Pyton3.8.10 Fire version = 0.5

file sample.py

import fire                                                                                                                                                                                                     
from fire import Fire                                                                                                                                                                                           

print(fire.__version__)                                                                                                                                                                                         

def sample(sequence:str):                                                                                                                                                                                       
    print(sequence, type(sequence))                                                                                                                                                                             

Fire(sample)   
$ python3 ./sample.py "00"                                                                                                                                                                                      
0.5.0                                                                                                                                                                                                           
0 <class 'int'>

Expected behavior: "00" string type

dbieber commented 9 months ago

Yes, Fire does not take into account type annotations at this time. While this could be a big improvement for Fire, it is not planned at this time.

Se-Hun commented 4 months ago

Is it clear?