You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(gazelle): Update resolve.go to provide more human-friendly error output (#2120)
Update the Resolver error messages in resolve.go to be easier to read.
While enabling gazelle in an existing repo, I found it somewhat
difficult to skim the error messages. This PR:
1. Adds a bit of whitespace to spread different pieces of information
out
2. Provides an additional remediation action for ambiguous import
resolution
3. Moves the filename and line number where the error is to the front of
the line.
4. Provides more concrete "gazelle:resolve py" directive examples for
each errored dep resolution.
Additionally, update a testcase to showcase the ambiguous import
resolution error case. See the `test.yaml` file diff for an example of
the old vs new error output.
Copy file name to clipboardExpand all lines: gazelle/python/testdata/invalid_imported_module/test.yaml
+15-2
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,20 @@
16
16
expect:
17
17
exit_code: 1
18
18
stderr: |
19
-
gazelle: ERROR: failed to validate dependencies for target "//:invalid_imported_module": "grpc" at line 16 from "__init__.py" is an invalid dependency: possible solutions:
19
+
gazelle: ERROR: failed to validate dependencies for target "//:invalid_imported_module":
20
+
21
+
"__init__.py", line 15: multiple targets (//foo:bar_1, //foo:bar_2) may be imported with "foo.bar": possible solutions:
22
+
1. Disambiguate the above multiple targets by removing duplicate srcs entries.
23
+
2. Use the '# gazelle:resolve py foo.bar TARGET_LABEL' BUILD file directive to resolve to one of the above targets.
24
+
25
+
"__init__.py", line 15: "foo" is an invalid dependency: possible solutions:
26
+
1. Add it as a dependency in the requirements.txt file.
27
+
2. Use the '# gazelle:resolve py foo TARGET_LABEL' BUILD file directive to resolve to a known dependency.
28
+
3. Ignore it with a comment '# gazelle:ignore foo' in the Python file.
29
+
30
+
gazelle: ERROR: failed to validate dependencies for target "//:invalid_imported_module":
31
+
32
+
"__init__.py", line 18: "grpc" is an invalid dependency: possible solutions:
20
33
1. Add it as a dependency in the requirements.txt file.
21
-
2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.
34
+
2. Use the '# gazelle:resolve py grpc TARGET_LABEL' BUILD file directive to resolve to a known dependency.
22
35
3. Ignore it with a comment '# gazelle:ignore grpc' in the Python file.
0 commit comments