From 0a8b189aa2ef5e146dcd6aa461c7ba67e979c430 2022-08-30 12:39:04 From: William Andrea Date: 2022-08-30 12:39:04 Subject: [PATCH] Show "maxlen" in deque repr "collections.deque" has a "maxlen" attribute that should be shown in its repr if defined, just like its default repr does. This was brought up on Stack Overflow: https://stackoverflow.com/questions/71981214/python-deque-maxlen-does-not-show --- diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py index 72f1435..f7feff9 100644 --- a/IPython/lib/pretty.py +++ b/IPython/lib/pretty.py @@ -908,6 +908,8 @@ def _deque_pprint(obj, p, cycle): cls_ctor = CallExpression.factory(obj.__class__.__name__) if cycle: p.pretty(cls_ctor(RawText("..."))) + elif obj.maxlen is not None: + p.pretty(cls_ctor(list(obj), maxlen=obj.maxlen)) else: p.pretty(cls_ctor(list(obj)))