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

Gracefully handle explicit transient=None #322

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion nbclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,12 @@ def process_message(
content = msg["content"]
self.log.debug("content: %s", content)

display_id = content.get("transient", {}).get("display_id", None)
# while it's tempting to go for a more concise
# display_id = content.get("transient", {}).get("display_id", None)
# this breaks if transient is explicitly set to None
transient = content.get("transient", {})
display_id = transient.get("display_id", None) if transient else None
Copy link
Member

Choose a reason for hiding this comment

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

I can be simply:

Suggested change
transient = content.get("transient", {})
display_id = transient.get("display_id", None) if transient else None
transient = content.get("transient")
display_id = transient.get("display_id") if transient else None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but of course! 🤦‍♂️


if display_id and msg_type in {"execute_result", "display_data", "update_display_data"}:
self._update_display_id(display_id, msg)

Expand Down
Loading