Skip to content
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

chore: reduce usage of 'from mod_foo import class_foo' #2872

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JohnVillalovos
Copy link
Member

@JohnVillalovos JohnVillalovos commented May 17, 2024

Reduce usage of doing:
from SOME_MODULE import SOME_CLASS_OR_FUNCTION

Instead use:
import SOME_MODULE

And then use the full module name. This improves readability and makes obvious to the reader where the class or function has come from.

@JohnVillalovos JohnVillalovos changed the title chore reduce usage of 'from mod_foo import class_foo' chore: reduce usage of 'from mod_foo import class_foo' May 17, 2024
Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

Thanks @JohnVillalovos I guess it makes sense to align as we have a huge mix now in the library.

But I think this PR doesn't really replace class/function imports, it replaces from-imports with plain imports. Which I think is not the idea behind Google's styleguide that I think this is trying to follow. See https://google.github.io/styleguide/pyguide.html#22-imports. I think their idea would be from requests import auth -> auth.AuthBase.

I'm not sure the full path is always needed when referencing especially with modern IDEs and code intelligence enabled on GitHub/GitLab?

Reduce usage of doing:
  from SOME_MODULE import SOME_CLASS_OR_FUNCTION

Instead use:
  import SOME_MODULE

And then use the full module name. This improves readability and makes
obvious to the reader where the class or function has come from.
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.

None yet

2 participants