You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
String hinted arguments passed numerical values should not be coerced #733
If a callable command function defines an argument with a string hint, e.g. arg: str, and a value of 1.10 is passed to it, then it receives an argument of type float with value 1.1 which has different meaning than the passed value.
This is particularly troublesome when dealing with versions since 1.1 is much different than 1.10.
Expected behavior
Fire should not coerce the value to a type different than the type hint, regardless of its format.
Then both python tp.py 1.10 and python tp.py --arg=1.10 print:
Hello! <class 'str'> 1.10
SetParseFns(arg=str) applies to this parameter for positional and named arguments; other parameters retain their normal parsing. The public decorator configures the parser independently of the annotation.
The guide's argument-parsing section explains the value-based inference and quoting. Ordinary shell quotes disappear before Fire receives the argument, so '1.10' alone does not force a string. Converting to str after parsing cannot recover the lost zero.
Activity
tevinch commentedon Nov 12, 2026
For this parameter, you can set Fire's parser explicitly in 0.7.1:
Then both
python tp.py 1.10andpython tp.py --arg=1.10print:SetParseFns(arg=str)applies to this parameter for positional and named arguments; other parameters retain their normal parsing. The public decorator configures the parser independently of the annotation.The guide's argument-parsing section explains the value-based inference and quoting. Ordinary shell quotes disappear before Fire receives the argument, so
'1.10'alone does not force a string. Converting tostrafter parsing cannot recover the lost zero.Runnable examples and subprocess checks cover the original command and preserving a string beside a numeric parameter, using Fire 0.7.1.