@@ -186,6 +186,7 @@ def the_function_to_deprecate():
186186
187187 def deprecate (obj , message = message , name = name , alternative = alternative ,
188188 pending = pending , obj_type = obj_type , addendum = addendum ):
189+ from matplotlib ._api import classproperty
189190
190191 if isinstance (obj , type ):
191192 if obj_type is None :
@@ -202,15 +203,16 @@ def finalize(wrapper, new_doc):
202203 obj .__init__ = functools .wraps (obj .__init__ )(wrapper )
203204 return obj
204205
205- elif isinstance (obj , property ):
206+ elif isinstance (obj , ( property , classproperty ) ):
206207 obj_type = "attribute"
207208 func = None
208209 name = name or obj .fget .__name__
209210 old_doc = obj .__doc__
210211
211- class _deprecated_property (property ):
212+ class _deprecated_property (type ( obj ) ):
212213 def __get__ (self , instance , owner ):
213- if instance is not None :
214+ if instance is not None or owner is not None \
215+ and isinstance (self , classproperty ):
214216 emit_warning ()
215217 return super ().__get__ (instance , owner )
216218
@@ -518,7 +520,7 @@ def empty_with_docstring(): """doc"""
518520
519521
520522@contextlib .contextmanager
521- def _suppress_matplotlib_deprecation_warning ():
523+ def suppress_matplotlib_deprecation_warning ():
522524 with warnings .catch_warnings ():
523525 warnings .simplefilter ("ignore" , MatplotlibDeprecationWarning )
524526 yield
0 commit comments