From 6e04afc18aca10586a2fd87dfb84ddfb4a1c3f10 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 23 Jan 2020 16:49:37 +0100 Subject: [PATCH] Simplify Legend.get_children. _legend_box is inited to a non-None value in _init_legend_box which is called in `__init__`, so the `if self._legend_box` check is unnecessary. --- lib/matplotlib/legend.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index d634b7ccc9a4..f00877ad37d3 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -885,13 +885,8 @@ def draw_frame(self, b): self.set_frame_on(b) def get_children(self): - """Return the list of child artists.""" - children = [] - if self._legend_box: - children.append(self._legend_box) - children.append(self.get_frame()) - - return children + # docstring inherited + return [self._legend_box, self.get_frame()] def get_frame(self): """Return the `~.patches.Rectangle` used to frame the legend."""