@@ -186,6 +186,7 @@ def the_function_to_deprecate():
186
186
187
187
def deprecate (obj , message = message , name = name , alternative = alternative ,
188
188
pending = pending , obj_type = obj_type , addendum = addendum ):
189
+ from matplotlib ._api import classproperty
189
190
190
191
if isinstance (obj , type ):
191
192
if obj_type is None :
@@ -202,15 +203,16 @@ def finalize(wrapper, new_doc):
202
203
obj .__init__ = functools .wraps (obj .__init__ )(wrapper )
203
204
return obj
204
205
205
- elif isinstance (obj , property ):
206
+ elif isinstance (obj , ( property , classproperty ) ):
206
207
obj_type = "attribute"
207
208
func = None
208
209
name = name or obj .fget .__name__
209
210
old_doc = obj .__doc__
210
211
211
- class _deprecated_property (property ):
212
+ class _deprecated_property (type ( obj ) ):
212
213
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 ):
214
216
emit_warning ()
215
217
return super ().__get__ (instance , owner )
216
218
@@ -518,7 +520,7 @@ def empty_with_docstring(): """doc"""
518
520
519
521
520
522
@contextlib .contextmanager
521
- def _suppress_matplotlib_deprecation_warning ():
523
+ def suppress_matplotlib_deprecation_warning ():
522
524
with warnings .catch_warnings ():
523
525
warnings .simplefilter ("ignore" , MatplotlibDeprecationWarning )
524
526
yield
0 commit comments