@@ -26,25 +26,20 @@ def _generate_deprecation_warning(
26
26
addendum = '' , * , removal = '' ):
27
27
if pending :
28
28
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 } '
36
33
if not message :
37
34
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
48
43
return warning_cls (message % dict (
49
44
func = name , name = name , obj_type = obj_type , since = since , removal = removal ,
50
45
alternative = alternative , addendum = addendum ))
@@ -295,7 +290,7 @@ def wrapper(*args, **kwargs):
295
290
warn_deprecated (
296
291
since , message = f"The { old !r} parameter of { func .__name__ } () "
297
292
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." )
299
294
kwargs [new ] = kwargs .pop (old )
300
295
return func (* args , ** kwargs )
301
296
@@ -390,12 +385,12 @@ def wrapper(*inner_args, **inner_kwargs):
390
385
warn_deprecated (
391
386
since , message = f"Additional positional arguments to "
392
387
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." )
394
389
elif is_varkwargs and arguments .get (name ):
395
390
warn_deprecated (
396
391
since , message = f"Additional keyword arguments to "
397
392
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." )
399
394
# We cannot just check `name not in arguments` because the pyplot
400
395
# wrappers always pass all arguments explicitly.
401
396
elif any (name in d and d [name ] != _deprecated_parameter
@@ -453,7 +448,7 @@ def wrapper(*args, **kwargs):
453
448
warn_deprecated (
454
449
since , message = "Passing the %(name)s %(obj_type)s "
455
450
"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." ,
457
452
name = name , obj_type = f"parameter of { func .__name__ } ()" )
458
453
return func (* args , ** kwargs )
459
454
0 commit comments