Thanks to visit codestin.com
Credit goes to github.com

Skip to content

API Deprecate if_delegate_has_method - #22830

Merged
thomasjpfan merged 8 commits into
scikit-learn:mainfrom
jeremiedbb:deprecate-if-delegate-has-method
Mar 17, 2022
Merged

API Deprecate if_delegate_has_method#22830
thomasjpfan merged 8 commits into
scikit-learn:mainfrom
jeremiedbb:deprecate-if-delegate-has-method

Conversation

@jeremiedbb

Copy link
Copy Markdown
Member

Fixes #20506

The decorator has been replaced by available_if everywhere.

@jeremiedbb jeremiedbb added the Quick Review For PRs that are quick to review label Mar 14, 2022
@jeremiedbb jeremiedbb added this to the 1.1 milestone Mar 14, 2022

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

I think we need to add this to:

To be removed in 1.0 (renaming of 0.25)
---------------------------------------

With "to be removed in 1.3".

Comment thread sklearn/utils/metaestimators.py Outdated
return lambda fn: _AvailableIfDescriptor(fn, check, attribute_name=fn.__name__)


# TODO remove in version 1.3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How do you feel about adding a syntax for TODO items?

Suggested change
# TODO remove in version 1.3
# TODO(1.3) Remove

This would make these items easier to grep for.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Anything that help finding these is good :)

self.delegate_names = delegate_names

def _check(self, obj):
warnings.warn(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This raises a warning when the method if_delegate_has_method decorates is called. There is the edge case, where if the deprecated method never gets called then the user would not know if_delegate_has_method was deprecated. This is kind of consistent with how we deprecate functions.

The alternative is to deprecate when if_delegate_has_method gets called, i.e. when the method gets wrapped. WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I hesitated but I found weird to have the deprecation warning when importing a module (where it's used to decorate a method for instance).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do not think this point is a blocker for this PR.

Comment thread sklearn/utils/metaestimators.py Outdated

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

self.delegate_names = delegate_names

def _check(self, obj):
warnings.warn(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do not think this point is a blocker for this PR.

@thomasjpfan
thomasjpfan merged commit b9bd2d5 into scikit-learn:main Mar 17, 2022
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Apr 6, 2022
arokem added a commit to arokem/AFQ-Insight-legacy that referenced this pull request Sep 5, 2023
@jeremiedbb
jeremiedbb deleted the deprecate-if-delegate-has-method branch September 3, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:utils Quick Review For PRs that are quick to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate if_delegate_has_method and replace with available_if

3 participants