Astropy: deprecated_renamed_argument fails for a removed keyword (not solved: when it is called as positional argument)

Created on 31 Jan 2020  路  3Comments  路  Source: astropy/astropy

UPDATE: It is still unsolved for when function below is called as myfunc(1, 200).


deprecated_renamed_argument allows one to deprecate a removed keyword argument. However, when doing so, the deprecated keyword cannot be set. It is always given its default value:

>>> from astropy.utils.decorators import deprecated_renamed_argument

>>> @deprecated_renamed_argument('b', None, '4.1')
>>> def myfunc(a, b=3):
>>>     print(a, b)
>>>     return

>>> myfunc(1, b=200)
1 3
WARNING: AstropyDeprecationWarning: "b" was deprecated in version 4.1 and will be removed in a future version.  [warnings]

The deprecated keyword value can be changed from the default if it is used as a positional argument, but in that case the deprecation warning is not raised:

>>> myfunc(1, 200)
1 200
Bug utils

All 3 comments

oh, wow, this is a mess.

I'll try to take care of it over the weekend.

I might have a fix. Please see #9981.

I wonder how many downstream packages are affected. Given that we have gotten no bug reports until now, this usage is probably uncommon.

thanks @pllim. It seems that my weekends are slipping away with not much code produced 馃槬

Was this page helpful?
0 / 5 - 0 ratings