Skip to content

Commit 259a5a2

Browse files
committed
Fix conftest target inclusion when disabling relative imports (by always
converting the import to an appropriate absolute import)
1 parent 4484c85 commit 259a5a2

File tree

26 files changed

+114
-11
lines changed

26 files changed

+114
-11
lines changed

gazelle/python/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes
476476

477477
for _, pyTestTarget := range pyTestTargets {
478478
if conftest != nil {
479-
conftestModule := Module{Name: strings.TrimSuffix(conftestFilename, ".py")}
479+
conftestModule := Module{Name: importSpecFromSrc(pythonProjectRoot, args.Rel, conftestFilename).Imp}
480480
if pyTestTarget.annotations.includePytestConftest == nil {
481481
// unset; default behavior
482482
pyTestTarget.addModuleDependency(conftestModule)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# gazelle:python_generation_mode file
2-
# gazelle:python_resolve_sibling_imports enabled
2+
# gazelle:python_resolve_sibling_imports true

gazelle/python/testdata/annotation_include_dep/BUILD.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
22

33
# gazelle:python_generation_mode file
4-
# gazelle:python_resolve_sibling_imports enabled
4+
# gazelle:python_resolve_sibling_imports true
55

66
py_library(
77
name = "__init__",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# gazelle:python_library_naming_convention my_$package_name$_library
22
# gazelle:python_binary_naming_convention my_$package_name$_binary
33
# gazelle:python_test_naming_convention my_$package_name$_test
4-
# gazelle:python_resolve_sibling_imports enabled
4+
# gazelle:python_resolve_sibling_imports true

gazelle/python/testdata/naming_convention/BUILD.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
33
# gazelle:python_library_naming_convention my_$package_name$_library
44
# gazelle:python_binary_naming_convention my_$package_name$_binary
55
# gazelle:python_test_naming_convention my_$package_name$_test
6-
# gazelle:python_resolve_sibling_imports enabled
6+
# gazelle:python_resolve_sibling_imports true
77

88
py_library(
99
name = "my_naming_convention_library",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# gazelle:python_resolve_sibling_imports enabled
1+
# gazelle:python_resolve_sibling_imports true

gazelle/python/testdata/sibling_imports/pkg/BUILD.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@rules_python//python:defs.bzl", "py_library", "py_test")
22

3-
# gazelle:python_resolve_sibling_imports enabled
3+
# gazelle:python_resolve_sibling_imports true
44

55
py_library(
66
name = "pkg",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
load("@rules_python//python:defs.bzl", "py_library")
22

3-
# gazelle:python_resolve_sibling_imports enabled
3+
# gazelle:python_resolve_sibling_imports true

gazelle/python/testdata/simple_test_with_conftest/BUILD.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@rules_python//python:defs.bzl", "py_library", "py_test")
22

3-
# gazelle:python_resolve_sibling_imports enabled
3+
# gazelle:python_resolve_sibling_imports true
44

55
py_library(
66
name = "simple_test_with_conftest",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
load("@rules_python//python:defs.bzl", "py_library")
2+
3+
# gazelle:python_resolve_sibling_imports false

0 commit comments

Comments
 (0)