-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
- PrettyPrinter version: 0.18
- Python version: 3.10
- Operating System: Linux
Description
Trying to prettyprint a PIL.Image.Image in an IPython console results in an AssertionError (no such error occurs without the ipython_repr_pretty extra being installed).
What I Did
The following is run in an IPython empty profile.
Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.3.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import prettyprinter as pp, PIL.Image, numpy as np; pp.install_extras(["ipython_repr_pretty"]); pp.cpprint(PIL.Image.fromarray(np.array([[1, 2], [3, 4]], dtype=np.uint16)))
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import prettyprinter as pp, PIL.Image, numpy as np; pp.install_extras(["ipython_repr_pretty"]); pp.cpprint(PIL.Image.fromarray(np.array([[1, 2], [3, 4]], dtype=np.uint16)))
File /usr/lib/python3.10/site-packages/prettyprinter/__init__.py:255, in cpprint(object, stream, indent, width, depth, compact, ribbon_width, max_seq_len, sort_dict_keys, style, end)
237 sdocs = python_to_sdocs(
238 object,
239 **_merge_defaults(
(...)
246 )
247 )
248 stream = (
249 # This is not in _default_config in case
250 # sys.stdout changes.
(...)
253 else stream
254 )
--> 255 colored_render_to_stream(stream, sdocs, style=style)
256 if end:
257 stream.write(end)
File /usr/lib/python3.10/site-packages/prettyprinter/color.py:203, in colored_render_to_stream(stream, sdocs, style, newline, separator)
200 if style is None:
201 style = default_style
--> 203 evald = list(sdocs)
205 if not evald:
206 return
File /usr/lib/python3.10/site-packages/prettyprinter/layout.py:255, in best_layout(doc, width, ribbon_frac, fitting_predicate, outcol, mode)
248 elif isinstance(doc, Contextual):
249 evaluated_doc = doc.fn(
250 indent=indent,
251 column=outcol,
252 page_width=width,
253 ribbon_width=ribbon_width,
254 )
--> 255 normalized = normalize_doc(evaluated_doc)
256 triplestack.append((indent, mode, normalized))
257 elif isinstance(doc, Annotated):
File /usr/lib/python3.10/site-packages/prettyprinter/doctypes.py:6, in normalize_doc(doc)
4 return NIL
5 return doc
----> 6 return doc.normalize()
File /usr/lib/python3.10/site-packages/prettyprinter/doctypes.py:57, in Concat.normalize(self)
55 propagate_broken = False
56 for doc in self.docs:
---> 57 doc = normalize_doc(doc)
58 if isinstance(doc, Concat):
59 normalized_docs.extend(doc.docs)
File /usr/lib/python3.10/site-packages/prettyprinter/doctypes.py:6, in normalize_doc(doc)
4 return NIL
5 return doc
----> 6 return doc.normalize()
File /usr/lib/python3.10/site-packages/prettyprinter/doctypes.py:201, in Group.normalize(self)
199 elif doc_normalized is NIL:
200 return NIL
--> 201 return Group(doc_normalized)
File /usr/lib/python3.10/site-packages/prettyprinter/doctypes.py:189, in Group.__init__(self, doc)
188 def __init__(self, doc):
--> 189 assert isinstance(doc, Doc)
190 self.doc = doc
AssertionError:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels