From 0a8b189aa2ef5e146dcd6aa461c7ba67e979c430 Mon Sep 17 00:00:00 2001 From: William Andrea Date: Sat, 23 Apr 2022 13:02:35 -0400 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 --- IPython/lib/pretty.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py index 72f143522df..f7feff9c3d3 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)))