Skip to content

MAINT: resolve pyflake F403 'from module import *' used #15366

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
merged 1 commit into from
Jan 23, 2020

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Jan 21, 2020

  • For external modules, resolve imported members
  • Most internal relative modules were ignored or marked noqa: F403
  • Convert a few internal absolute imports to relative imports

Found using:

flake8 --select=F403 | grep -v "'from \." | sort

the regular expression ignores internal relative imports

@mwtoews mwtoews force-pushed the F403 branch 4 times, most recently from 353f1f7 to 6a109c5 Compare January 21, 2020 10:03
@mattip
Copy link
Member

mattip commented Jan 21, 2020

not sure we need the extra comment # noqa: F403, but I guess it doesn't hurt and will make additional cleanup easier to find

Copy link
Contributor Author

@mwtoews mwtoews left a comment

Choose a reason for hiding this comment

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

not sure we need the extra comment # noqa: F403, but I guess it doesn't hurt and will make additional cleanup easier to find

For reference, see flake8's dcoumentation on "In-line Ignoring Errors". For any users of flake8, this message will normally be hidden for this line of code. It is also my mark to acknowledge and accept the use of from module import *, which is generally discouraged.

@@ -14,7 +14,7 @@
uses_accelerate_framework, get_sgemv_fix
)
from numpy.compat import npy_load_module
from setup_common import *
from setup_common import * # noqa: F403
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the record, I had difficulties making this into either a relative or absolute import. I can't recall exactly, but I think I tried from .setup_common import * and from numpy.core.setup_common import *, but both bombed Travis CI tests. If anyone knows why, I'd be interested.

* For external modules, resolve imported members
* Most internal relative modules were ignored or marked noqa: F403
* Convert a few internal absolute imports to relative imports
@mattip
Copy link
Member

mattip commented Jan 23, 2020

Putting this in. I think we should limit the code churn simply to change relative/absolute imports. Both styles are commonly used, and it is not worth the effort to unify the code base.

@mattip mattip merged commit 61c5c5d into numpy:master Jan 23, 2020
@mwtoews mwtoews deleted the F403 branch March 9, 2021 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants