From 9b805323c0dbb19af2cea10521d9d6fa6061f16d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 20 Jul 2023 15:23:00 -0400 Subject: [PATCH] Fix removal of Figure-level artists PyCharm has been warning that `Artist.figure` should be a `Figure|None`, not a `bool` as is set in this block. Based on the previous section of code, I think setting the figure to stale (if the Axes was not already set stale, meaning the Artist was on a Figure *only*) was the intended behaviour. --- lib/matplotlib/artist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index b54a6cc42094..e89180387103 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -249,9 +249,9 @@ def remove(self): _ax_flag = True if self.figure: - self.figure = None if not _ax_flag: - self.figure = True + self.figure.stale = True + self.figure = None else: raise NotImplementedError('cannot remove artist')