Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6080c21

Browse files
authored
Merge pull request #12700 from timhoffm/auto-backport-of-pr-12653-on-v3.0.x
Backport PR #12653: Don't warn when accessing deprecated properties f…
2 parents 363f06e + 7d4fa75 commit 6080c21

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lib/matplotlib/cbook/deprecation.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,36 @@ def finalize(wrapper, new_doc):
190190
obj.__doc__ = new_doc
191191
obj.__init__ = wrapper
192192
return obj
193+
194+
elif isinstance(obj, property):
195+
obj_type = "attribute"
196+
func = None
197+
name = name or obj.fget.__name__
198+
old_doc = obj.__doc__
199+
200+
class _deprecated_property(property):
201+
def __get__(self, instance, owner):
202+
if instance is not None:
203+
from . import _warn_external
204+
_warn_external(message, category)
205+
return super().__get__(instance, owner)
206+
207+
def __set__(self, instance, value):
208+
if instance is not None:
209+
from . import _warn_external
210+
_warn_external(message, category)
211+
return super().__set__(instance, value)
212+
213+
def __delete__(self, instance):
214+
if instance is not None:
215+
from . import _warn_external
216+
_warn_external(message, category)
217+
return super().__delete__(instance)
218+
219+
def finalize(_, new_doc):
220+
return _deprecated_property(
221+
fget=obj.fget, fset=obj.fset, fdel=obj.fdel, doc=new_doc)
222+
193223
else:
194224
obj_type = "function"
195225
if isinstance(obj, classmethod):

0 commit comments

Comments
 (0)