-
-
Notifications
You must be signed in to change notification settings - Fork 591
709/from imports #760
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
f0rmiga
merged 11 commits into
bazel-contrib:main
from
aptenodytes-forsteri:709/from-imports
Aug 4, 2022
Merged
709/from imports #760
f0rmiga
merged 11 commits into
bazel-contrib:main
from
aptenodytes-forsteri:709/from-imports
Aug 4, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add test case with `from __future__ import print_function`.
…les_python into 709/from-imports
- Make sure that `from foo import bar, baz` works. - Add test case for this.
- Keep error the same as before.
f0rmiga
approved these changes
Aug 3, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
from foo import bar
adds//foo
as a dep instead of//foo/bar
.from foo.bar import baz
adds//foo/bar
as a dep instead of//foo/bar:baz
(when//foo/bar:baz
is a separate py_library that contains foo/bar/baz.py as a source).from google.cloud import aiplatform
does not add"@gazelle_python_test_google_cloud_aiplatform//:pkg",
as a dep (fails to resolvefrom
imports for pip packages).Issue Number: #709
What is the new behavior?
When gazelle encounters
from foo.bar import baz
, try to resolve, in order from most specific to least specific:This way, if
foo.bar.baz
is in the manifest file or in the index of existing rules (e.g. from a rule that contains the source file foo/bar/baz, it can be found). Iffoo.bar.baz
can't be resolved, tryfoo.bar
(maybebaz
is just a function or variable infoo/bar.py
).Does this PR introduce a breaking change?
Other information
May want to consider antagonistic cases - are there cases where imports are truly ambiguous?