Skip to content

Preserve value of deprecated parameters without replacement#7552

Merged
lagru merged 1 commit intoscikit-image:mainfrom
lagru:fix-deprecate-parameter
Oct 3, 2024
Merged

Preserve value of deprecated parameters without replacement#7552
lagru merged 1 commit intoscikit-image:mainfrom
lagru:fix-deprecate-parameter

Conversation

@lagru
Copy link
Copy Markdown
Member

@lagru lagru commented Sep 26, 2024

Description

Even if a parameter is deprecated, a value passed to it must be preserved during the deprecation cycle! Othwerwise, we effectively remove the deprecated behavior before the cycle is complete.

This is only relevant if there's no replacement for the deprecated parameter. In that case, the given value preserved and passed to the replacing parameter, and the deprecated one can be overwritten with DEPRECATED.

E.g.

from skimage._shared.utils import deprecate_parameter, DEPRECATED

@deprecate_parameter("a", start_version="X", stop_version="X+2")
def foo(a=DEPRECATED):
    if a is True:
        print("Can still use deprecated behavior!")

foo(True)

should warn and print but only warns on main because it silently replaces with DEPRECATED.

Thankfully, it doesn't look like we are currently using the decorator in a way that is affected by this bug. Discovered while preparing #7353.

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

During deprecation cycles, preserve the value of deprecated parameters
that don't have a new parameter as a replacement.

Even if a parameter is deprecated, a value passed to it must be
preserved during the deprecation cycle! Othwerwise, we effectively
remove the deprecated behavior before the cycle is complete.

This is only relevant if there's no replacement for the deprecated
parameter. In that case, the given value preserved and passed to the
replacing parameter, and the deprecated one can be overwritten with
`DEPRECATED`.
@lagru lagru added the 🔧 type: Maintenance Refactoring and maintenance of internals label Sep 26, 2024
@lagru lagru requested review from mkcor and stefanv September 26, 2024 12:40
@lagru lagru added this to the 0.25 milestone Sep 26, 2024
@lagru
Copy link
Copy Markdown
Member Author

lagru commented Sep 26, 2024

This is technically a bug fix, but I'm not labeling it as such because this didn't affect our users as far as I'm aware.

Copy link
Copy Markdown
Member

@mkcor mkcor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lagru lagru added the 👍 1st approval Needs 2nd approval to merge label Oct 1, 2024
@lagru lagru merged commit 8e37f77 into scikit-image:main Oct 3, 2024
@lagru lagru deleted the fix-deprecate-parameter branch October 3, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 type: Maintenance Refactoring and maintenance of internals 👍 1st approval Needs 2nd approval to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants