Skip to content

[MRG] MNT Uses pep562 to import private methods #15431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

thomasjpfan
Copy link
Member

Reference Issues/PRs

Resolves #15415
Alternative to #15419

What does this implement/fix? Explain your changes.

Lets backport pep562, since we may be using it for enable_experimental_* as well.

@NicolasHug
Copy link
Member

I think this is missing

import sys
PY37 = sys.version_info >= (3, 7)
if not PY37:
    Pep562(__name__)

@@ -143,7 +148,9 @@ def test_tabs():
'feature_extraction._hashing_fast' in modname):
continue

# because we don't import
# Do not check deprecated paths
if modname in DEPRECATED_MODULE_NAMES:
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this? There shouldn't be any tab anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

The Pep562 wraps the original module and is an instance, which means getsource will fail in this case.

I updated this PR by unwrapping the instance and grab the underlying _module.

@@ -133,6 +134,10 @@ def test_docstring_parameters():
raise AssertionError("Docstring Error:\n" + msg)


DEPRECATED_MODULE_NAMES = set(
Copy link
Member

Choose a reason for hiding this comment

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

declare in the function where it's used?

@@ -145,6 +146,12 @@ def test_tabs():

# because we don't import
mod = importlib.import_module(modname)

# unwrap to get module because Pep562 backport wraps the original
# module
Copy link
Member

Choose a reason for hiding this comment

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

Mark as to be removed in 0.24 or when Pep562 isn't used anymore

?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can also used this for experimental features for a better error message?

Copy link
Member

Choose a reason for hiding this comment

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

still worth a tag?

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Nice! Thanks @thomasjpfan !

@rth rth merged commit f447dbc into scikit-learn:master Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Feedback after scikit-learn module privatization
4 participants