Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this PR, workflows and activities could not return dicts with non-string keys. E.g. something as simple as this fails:
This is surprising to users because a pervasive feature of the Python SDK is that type annotations are used to make the data converter do the right thing: the type annotation should be "honored" there.
The behavior happens because (1) we default to json/plain encoding, (2) in JSON keys must be strings, (3) the Python JSON encoder accepts str, int, float, bool, None dict keys, silently encoding them as valid JSON string representations, (4) although the type annotation is typically present (either from a type annotation in workflow/activity code) or less commonly because a user supplied the return_type argument) to "fix" the key type, our data converter doesn't do that. But JSON encoding is an implementation detail of the Python SDK.
The SDK's
pydantic_data_converter
has no problem with dict types like that above. This PR makes our default data converter support them also.