google/python-fire

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

kanaryayi opened this issue · 2 comments

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

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.