Repository navigation
docs(helpers): note that whole numbers in a data Part come back as floats - #1373
carstenpiepel wants to merge 2 commits into
Conversation
…oats google.protobuf.Value stores every number as a double, so an integer placed in a data Part is read back as a float on every transport. Document this on new_data_part and get_data_parts, add a bullet to the v1.0 migration guide with the client-side workaround, and pin the behavior with a test. Fixes a2aproject#1328 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
🧪 Code Coverage (vs
|
| @@ -471,6 +471,14 @@ def test_get_data_parts_empty() -> None: | |||
| assert get_data_parts(parts) == [] | |||
|
|
|||
|
|
|||
There was a problem hiding this comment.
Please "invert" the tests logic. Assuring that int is converted to float marks it as expected behaviour in SDK (but it isn't)
Instead, write a test which ensures that int is converted to int and mark it as @pytests.mark.xfail (we expect it to fail) with strict flag set to True
There was a problem hiding this comment.
Done. The test now asserts that integers stay integers and is marked xfail with strict=True, with the issue URL as the reason. I also changed the PR body from Fixes to Refs, since the test treats the issue as still open.
…il strict Review feedback: a passing test that asserts int becomes float would record the conversion as intended. Assert the desired behavior instead and mark it strict xfail, so CI flags the moment it starts passing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@Iwaniukooo11 the requested change is pushed: the test now expects integers to stay integers and is marked xfail with strict=True. |
Description
Whole numbers placed in a data Part come back as floats. For example,
4326becomes4326.0. This happens becausegoogle.protobuf.Valuestores every number as a double. It affects every transport and is not a spec violation, since JSON does not distinguish the two.As agreed in #1328, this PR documents the behavior and does not change it.
Add a short note to the docstrings of
new_data_partandget_data_parts.Add one bullet to the v1.0 migration guide with the client-side workaround.
Add a strict xfail test that expects integers to stay integers, so CI flags it when the behavior changes.
Follow the
CONTRIBUTINGGuide.Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
Ensure the tests and linter pass (Run
bash scripts/format.shfrom the repository root to format)Appropriate docs were updated (if necessary)
Refs #1328 🦕
🤖 Generated with Claude Code