File tree Expand file tree Collapse file tree 8 files changed +15
-4
lines changed
gazelle/python/testdata/sibling_imports_disabled Expand file tree Collapse file tree 8 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 11# gazelle:python_resolve_sibling_imports false
2+ # gazelle:experimental_allow_relative_imports true
Original file line number Diff line number Diff line change 11load("@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
56py_library(
67 name = "sibling_imports_disabled",
Original file line number Diff line number Diff line change 22
33This test case asserts that imports from sibling modules are NOT resolved as
44absolute 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
Original file line number Diff line number Diff line change 1- # gazelle:python_resolve_sibling_imports false
Original file line number Diff line number Diff line change 11load("@rules_python//python:defs.bzl", "py_library", "py_test")
22
3- # gazelle:python_resolve_sibling_imports false
4-
53py_library(
64 name = "pkg",
75 srcs = [
86 "__init__.py",
97 "a.py",
108 "b.py",
9+ "typing.py",
1110 ],
1211 visibility = ["//:__subpackages__"],
1312)
1413
1514py_test(
1615 name = "test_util",
1716 srcs = ["test_util.py"],
17+ deps = [":pkg"],
1818)
1919
2020py_test(
Original file line number Diff line number Diff line change 1+ from .b import run
2+ from .typing import A
Original file line number Diff line number Diff line change 1+ A = 1
Original file line number Diff line number Diff line change 1+ from typing import Iterable
2+
13import a
24import test_util
35from b import run
You can’t perform that action at this time.
0 commit comments