Skip to content

Commit 29e815a

Browse files
committed
Add more test cases to sibling_imports_disabled
1 parent 9f69c62 commit 29e815a

File tree

8 files changed

+15
-4
lines changed

8 files changed

+15
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# gazelle:python_resolve_sibling_imports false
2+
# gazelle:experimental_allow_relative_imports true

gazelle/python/testdata/sibling_imports_disabled/BUILD.out

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

33
# gazelle:python_resolve_sibling_imports false
4+
# gazelle:experimental_allow_relative_imports true
45

56
py_library(
67
name = "sibling_imports_disabled",

gazelle/python/testdata/sibling_imports_disabled/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
This test case asserts that imports from sibling modules are NOT resolved as
44
absolute imports when the `python_resolve_sibling_imports` directive is
5-
disabled. It covers 3 different types of imports in `pkg/unit_test.py`:
5+
disabled. It covers different types of imports in `pkg/unit_test.py`:
66

77
- `import a` - resolves to the root-level `a.py` instead of the sibling
88
`pkg/a.py`
9+
- `from typing import Iterable` - resolves to the stdlib `typing` module
10+
(not the sibling `typing.py`).
11+
- `from .b import run` / `from .typing import A` - resolves to the sibling
12+
`pkg/b.py` / `pkg/typing.py` (with
13+
`gazelle:experimental_allow_relative_imports` enabled)
914
- `import test_util` - resolves to the root-level `test_util.py` instead of
1015
the sibling `pkg/test_util.py`
1116
- `from b import run` - resolves to the root-level `b.py` instead of the
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# gazelle:python_resolve_sibling_imports false

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

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

3-
# gazelle:python_resolve_sibling_imports false
4-
53
py_library(
64
name = "pkg",
75
srcs = [
86
"__init__.py",
97
"a.py",
108
"b.py",
9+
"typing.py",
1110
],
1211
visibility = ["//:__subpackages__"],
1312
)
1413

1514
py_test(
1615
name = "test_util",
1716
srcs = ["test_util.py"],
17+
deps = [":pkg"],
1818
)
1919

2020
py_test(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .b import run
2+
from .typing import A
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A = 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Iterable
2+
13
import a
24
import test_util
35
from b import run

0 commit comments

Comments
 (0)