From bb5d40071d19d5861725c14e9d78a5c4143a3399 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 27 Oct 2018 22:15:29 +0200 Subject: [PATCH] Don't warn when accessing deprecated properties from the class. Otherwise, we get a lot of spurious warnings from inspection tools such as pydoc. --- lib/matplotlib/cbook/deprecation.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/cbook/deprecation.py b/lib/matplotlib/cbook/deprecation.py index e18169fa2173..9885ae8210d7 100644 --- a/lib/matplotlib/cbook/deprecation.py +++ b/lib/matplotlib/cbook/deprecation.py @@ -201,18 +201,21 @@ def finalize(wrapper, new_doc): class _deprecated_property(property): def __get__(self, instance, owner): - from . import _warn_external - _warn_external(message, category) + if instance is not None: + from . import _warn_external + _warn_external(message, category) return super().__get__(instance, owner) def __set__(self, instance, value): - from . import _warn_external - _warn_external(message, category) + if instance is not None: + from . import _warn_external + _warn_external(message, category) return super().__set__(instance, value) def __delete__(self, instance): - from . import _warn_external - _warn_external(message, category) + if instance is not None: + from . import _warn_external + _warn_external(message, category) return super().__delete__(instance) def finalize(_, new_doc):