@@ -26,25 +26,20 @@ def _generate_deprecation_warning(
2626 addendum = '' , * , removal = '' ):
2727 if pending :
2828 if removal :
29- raise ValueError (
30- "A pending deprecation cannot have a scheduled removal" )
31- else :
32- if not removal :
33- macro , meso , * _ = since .split ('.' )
34- removal = f'{ macro } .{ int (meso ) + 2 } '
35- removal = f"in { removal } "
29+ raise ValueError ("A pending deprecation cannot have a scheduled removal" )
30+ elif removal == '' :
31+ macro , meso , * _ = since .split ('.' )
32+ removal = f'{ macro } .{ int (meso ) + 2 } '
3633 if not message :
3734 message = (
38- ("The %(name)s %(obj_type)s" if obj_type else "%(name)s" )
39- + (" will be deprecated in a future version"
40- if pending else
41- " was deprecated in Matplotlib %(since)s and will be removed %(removal)s"
42- )
43- + "."
44- + (" Use %(alternative)s instead." if alternative else "" )
45- + (" %(addendum)s" if addendum else "" ))
46- warning_cls = (PendingDeprecationWarning if pending
47- else MatplotlibDeprecationWarning )
35+ ("The %(name)s %(obj_type)s" if obj_type else "%(name)s" ) +
36+ (" will be deprecated in a future version" if pending else
37+ (" was deprecated in Matplotlib %(since)s" +
38+ (" and will be removed in %(removal)s" if removal else "" ))) +
39+ "." +
40+ (" Use %(alternative)s instead." if alternative else "" ) +
41+ (" %(addendum)s" if addendum else "" ))
42+ warning_cls = PendingDeprecationWarning if pending else MatplotlibDeprecationWarning
4843 return warning_cls (message % dict (
4944 func = name , name = name , obj_type = obj_type , since = since , removal = removal ,
5045 alternative = alternative , addendum = addendum ))
@@ -295,7 +290,7 @@ def wrapper(*args, **kwargs):
295290 warn_deprecated (
296291 since , message = f"The { old !r} parameter of { func .__name__ } () "
297292 f"has been renamed { new !r} since Matplotlib { since } ; support "
298- f"for the old name will be dropped %(removal)s." )
293+ f"for the old name will be dropped in %(removal)s." )
299294 kwargs [new ] = kwargs .pop (old )
300295 return func (* args , ** kwargs )
301296
@@ -390,12 +385,12 @@ def wrapper(*inner_args, **inner_kwargs):
390385 warn_deprecated (
391386 since , message = f"Additional positional arguments to "
392387 f"{ func .__name__ } () are deprecated since %(since)s and "
393- f"support for them will be removed %(removal)s." )
388+ f"support for them will be removed in %(removal)s." )
394389 elif is_varkwargs and arguments .get (name ):
395390 warn_deprecated (
396391 since , message = f"Additional keyword arguments to "
397392 f"{ func .__name__ } () are deprecated since %(since)s and "
398- f"support for them will be removed %(removal)s." )
393+ f"support for them will be removed in %(removal)s." )
399394 # We cannot just check `name not in arguments` because the pyplot
400395 # wrappers always pass all arguments explicitly.
401396 elif any (name in d and d [name ] != _deprecated_parameter
@@ -453,7 +448,7 @@ def wrapper(*args, **kwargs):
453448 warn_deprecated (
454449 since , message = "Passing the %(name)s %(obj_type)s "
455450 "positionally is deprecated since Matplotlib %(since)s; the "
456- "parameter will become keyword-only %(removal)s." ,
451+ "parameter will become keyword-only in %(removal)s." ,
457452 name = name , obj_type = f"parameter of { func .__name__ } ()" )
458453 return func (* args , ** kwargs )
459454
0 commit comments