Closed eliasmistler closed 1 year ago
I agree, it's a problem, but not unique to the Deprecated library.
The "action" parameter is used with the warnings.filterwarnings()
function to define the behavior of warnings in a specific part of the Python code.
The value "once" indicates that the warning should only be reported the first time it is encountered. After that, the warning will no longer be signaled even if it occurs again later.
When specifying the action at the deprecated function level, we use a context manager that allows the warning behavior to be modified locally to the function and thus restored at the end of the function call. This is required so as not to modify the application's global context. Indeed, in the case of "once", this has the effect of restoring the internal call counter, so a warning message is issued each time.
One way around this problem is not to specify the parameter at all, as "once" is the default value.
Expected Behavior
When setting the
action="once"
option, the deprecation warning should only be logged once.Actual Behavior
The deprecation warning is displayed every time the function is called:
Environment