Skip to content

STYLE keep local imports relative #39902

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

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Feb 19, 2021

  • Ensure all linting tests pass, see here for how to run them

xref this comment:

more generally, i like relative imports for same-directory as it clarified dependency structure

+1, I also find this helpful. I think it should certainly be doable to have a check that relative imports are never outside the local directory

@jorisvandenbossche @jbrockmendel is this what you had in mind?

Like this, imports in the same folder are relative, and those outside are absolute.

So, for example, in pandas/_testing/_io.py:

  • from pandas.io.common import urlopen stays absolute
  • from pandas._testing.contexts import ensure_clean becomes from .contexts import ensure_clean

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

-1 on this
let's leave imports alone for now

@MarcoGorelli
Copy link
Member Author

Sure 👍

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.

2 participants