Skip to content

Commit

Permalink
fix: none check on import loading (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas authored Jan 17, 2024
1 parent c263b4d commit 921e6e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rplugin/python3/molten/outputchunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,16 @@ def _from_plaintext(text: str) -> OutputChunk:

for mimetype, process_func in special_mimetypes:
try:
maybe_data = data.get(mimetype)
maybe_data = None
if data is not None:
maybe_data = data.get(mimetype)
if maybe_data is not None:
chunk = process_func(maybe_data) # type: ignore
break
except ImportError:
continue

if chunk is None:
if chunk is None and data is not None:
# handle arbitrary images
for mimetype in data.keys():
match mimetype.split("/"):
Expand All @@ -291,9 +293,11 @@ def _from_plaintext(text: str) -> OutputChunk:

if chunk is None:
# fallback to plain text if there's nothing else
if data.get("text/plain"):
if data is not None and data.get("text/plain"):
chunk = _from_plaintext(data["text/plain"])
else:
if data == None:
data = {}
chunk = BadOutputChunk(list(data.keys()))

chunk.jupyter_data = data
Expand Down

0 comments on commit 921e6e9

Please sign in to comment.