Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

yushan26
Copy link
Contributor

@yushan26 yushan26 commented Jul 10, 2025

A python import may be imported as:

from foo.bar.application.\
    pipeline.model import (
    Baz
)

However, gazelle fails to resolve this import with the error:
line 30: "foo.bar.application.pipeline.model\\\n pipeline.mode.Baz" is an invalid dependency:

Clean up the imports such that whitespace and \n are removed from the import path.

@yushan26 yushan26 changed the title fix(gazelle) Clean python imports fix(gazelle) Cleanup python imports Jul 10, 2025
@yushan26 yushan26 requested a review from rickeylev as a code owner July 10, 2025 22:30
Copy link
Collaborator

@dougthor42 dougthor42 left a comment

Choose a reason for hiding this comment

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

Thanks! I'm somewhat surprised that the underlying tree-sitter parser doesn't handle this.

I know you already have the go tests, but lets also add a test case to gazelle/python/testdata/from_imports/imports_nested_var/__init__.py:

 # baz is a variable in foo/bar/baz.py
 from foo.bar.baz import baz
+
+from foo\
+    .bar.\
+        baz import (
+                baz
+                )

Given that this is the same import as the previous line, the BUILD.out shouldn't change.

@yushan26
Copy link
Contributor Author

@dougthor42 Thanks for the review! Can you take another look?

@yushan26 yushan26 changed the title fix(gazelle) Cleanup python imports fix(gazelle) Update gazelle to properly process multi-line python imports Jul 14, 2025
@dougthor42 dougthor42 enabled auto-merge July 14, 2025 23:47
@dougthor42 dougthor42 added this pull request to the merge queue Jul 14, 2025
Merged via the queue into bazel-contrib:main with commit 6f27511 Jul 15, 2025
3 checks passed
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.

3 participants