Fixes incorrect casting into int for numbers in string format (#384)

This commit is contained in:
Pol Avec 2025-03-27 10:48:48 -04:00 • committed by David Soria Parra
commit 4e3c196941
No known key found for this signature in database

View file

@ -399,3 +399,18 @@ def test_complex_function_json_schema():
"title": "complex_arguments_fnArguments",
"type": "object",
}
def test_str_vs_int():
"""
Test that string values are kept as strings even when they contain numbers,
while numbers are parsed correctly.
"""
def func_with_str_and_int(a: str, b: int):
return a
meta = func_metadata(func_with_str_and_int)
result = meta.pre_parse_json({"a": "123", "b": 123})
assert result["a"] == "123"
assert result["b"] == 123