@@ -24,16 +24,16 @@ class MatplotlibDeprecationWarning(UserWarning):
2424def _generate_deprecation_warning (
2525 since , message = '' , name = '' , alternative = '' , pending = False ,
2626 obj_type = 'attribute' , addendum = '' , * , removal = '' ):
27-
28- if removal == "" :
29- removal = {"2.2" : "in 3.1" , "3.0" : "in 3.2" , "3.1" : "in 3.3" }.get (
30- since , "two minor releases later" )
31- elif removal :
32- if pending :
27+ if pending :
28+ if removal :
3329 raise ValueError (
3430 "A pending deprecation cannot have a scheduled removal" )
35- removal = "in {}" .format (removal )
36-
31+ else :
32+ if removal :
33+ removal = "in {}" .format (removal )
34+ else :
35+ removal = {"2.2" : "in 3.1" , "3.0" : "in 3.2" , "3.1" : "in 3.3" }.get (
36+ since , "two minor releases later" )
3737 if not message :
3838 message = (
3939 "\n The %(name)s %(obj_type)s"
@@ -46,10 +46,8 @@ def _generate_deprecation_warning(
4646 + "."
4747 + (" Use %(alternative)s instead." if alternative else "" )
4848 + (" %(addendum)s" if addendum else "" ))
49-
5049 warning_cls = (PendingDeprecationWarning if pending
5150 else MatplotlibDeprecationWarning )
52-
5351 return warning_cls (message % dict (
5452 func = name , name = name , obj_type = obj_type , since = since , removal = removal ,
5553 alternative = alternative , addendum = addendum ))
0 commit comments