Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add logic to serialize objects of Send class #722

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gcalabria
Copy link

@gcalabria gcalabria commented Jul 31, 2024

Closes #721

Copy link

cla-bot bot commented Jul 31, 2024

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Guilherme Calabria Lopes.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@@ -87,6 +89,8 @@ def default(obj) -> Any:
"""Default serialization for well known objects."""
if isinstance(obj, BaseModel):
return obj.dict()
if isinstance(obj, Send):
return {"node": obj.node, "arg": obj.arg}
return super().default(obj)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of super without a class context is a bug here. Can we give the default serializer more powers to allow any object to be become json serializable?

Suggested change
return super().default(obj)
try:
return obj.__dict__()
except:
pass
raise TypeError(f"Object of type {obj.__class__.__name__} is not JSON serializable")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: TypeError: Type is not JSON serializable: Send
2 participants