Skip to content

Commit 92940a4

Browse files
committed
Improve test case, adding a case of the deps being fully removed,
and a case of deps being only partially removed.
1 parent 86ba0a8 commit 92940a4

File tree

14 files changed

+62
-42
lines changed

14 files changed

+62
-42
lines changed
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
load("@rules_python//python:defs.bzl", "py_library")
2-
3-
py_library(
4-
name = "clear_out_deps",
5-
srcs = ["__init__.py"],
6-
deps = [":removed_a"],
7-
visibility = ["//:__subpackages__"],
8-
pyi_deps = [":removed_b"],
9-
)
1+
# gazelle:python_generate_pyi_deps true
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
load("@rules_python//python:defs.bzl", "py_library")
2-
3-
py_library(
4-
name = "clear_out_deps",
5-
srcs = ["__init__.py"],
6-
visibility = ["//:__subpackages__"],
7-
)
1+
# gazelle:python_generate_pyi_deps true

gazelle/python/testdata/clear_out_deps/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
This test case asserts that an existing `py_library` specifying `deps` and
44
`pyi_deps` have these attributes removed if the corresponding imports are
55
removed.
6+
7+
`a/BUILD.in` declares `deps`/`pyi_deps` on non-existing libraries, `b/BUILD.in` declares dependency on `//a`
8+
without a matching import, and `c/BUILD.in` declares both `deps` and `pyi_deps` as `["//a", "//b"]`, but
9+
it should have only `//a` as `deps` and only `//b` as `pyi_deps`.

gazelle/python/testdata/clear_out_deps/__init__.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_python//python:defs.bzl", "py_library")
2+
3+
py_library(
4+
name = "a",
5+
srcs = ["__init__.py"],
6+
pyi_deps = ["//:nonexistent_pyi_dep"],
7+
visibility = ["//:__subpackages__"],
8+
deps = ["//nonexistent_dep"],
9+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@rules_python//python:defs.bzl", "py_library")
2+
3+
py_library(
4+
name = "a",
5+
srcs = ["__init__.py"],
6+
visibility = ["//:__subpackages__"],
7+
)

gazelle/python/testdata/clear_out_deps/a/__init__.py

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_python//python:defs.bzl", "py_library")
2+
3+
py_library(
4+
name = "b",
5+
srcs = ["__init__.py"],
6+
pyi_deps = ["//a"],
7+
visibility = ["//:__subpackages__"],
8+
deps = ["//a"],
9+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@rules_python//python:defs.bzl", "py_library")
2+
3+
py_library(
4+
name = "b",
5+
srcs = ["__init__.py"],
6+
visibility = ["//:__subpackages__"],
7+
)

gazelle/python/testdata/clear_out_deps/b/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)