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?