Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gazelle/python/kinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var pyKinds = map[string]rule.KindInfo{
},
ResolveAttrs: map[string]bool{
"deps": true,
"pyi_deps": true,
},
},
pyLibraryKind: {
Expand All @@ -62,6 +63,7 @@ var pyKinds = map[string]rule.KindInfo{
},
ResolveAttrs: map[string]bool{
"deps": true,
"pyi_deps": true,
},
},
pyTestKind: {
Expand All @@ -78,6 +80,7 @@ var pyKinds = map[string]rule.KindInfo{
},
ResolveAttrs: map[string]bool{
"deps": true,
"pyi_deps": true,
},
},
}
Expand Down
1 change: 1 addition & 0 deletions gazelle/python/testdata/clear_out_deps/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# gazelle:python_generate_pyi_deps true
1 change: 1 addition & 0 deletions gazelle/python/testdata/clear_out_deps/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# gazelle:python_generate_pyi_deps true
9 changes: 9 additions & 0 deletions gazelle/python/testdata/clear_out_deps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Clearing deps / pyi_deps

This test case asserts that an existing `py_library` specifying `deps` and
`pyi_deps` have these attributes removed if the corresponding imports are
removed.

`a/BUILD.in` declares `deps`/`pyi_deps` on non-existing libraries, `b/BUILD.in` declares dependency on `//a`
without a matching import, and `c/BUILD.in` declares both `deps` and `pyi_deps` as `["//a", "//b"]`, but
it should have only `//a` as `deps` and only `//b` as `pyi_deps`.
1 change: 1 addition & 0 deletions gazelle/python/testdata/clear_out_deps/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a Bazel workspace for the Gazelle test data.
9 changes: 9 additions & 0 deletions gazelle/python/testdata/clear_out_deps/a/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_python//python:defs.bzl", "py_library")

py_library(
name = "a",
srcs = ["__init__.py"],
pyi_deps = ["//:nonexistent_pyi_dep"],
visibility = ["//:__subpackages__"],
deps = ["//nonexistent_dep"],
)
7 changes: 7 additions & 0 deletions gazelle/python/testdata/clear_out_deps/a/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("@rules_python//python:defs.bzl", "py_library")

py_library(
name = "a",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
Empty file.
9 changes: 9 additions & 0 deletions gazelle/python/testdata/clear_out_deps/b/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_python//python:defs.bzl", "py_library")

py_library(
name = "b",
srcs = ["__init__.py"],
pyi_deps = ["//a"],
visibility = ["//:__subpackages__"],
deps = ["//a"],
)
7 changes: 7 additions & 0 deletions gazelle/python/testdata/clear_out_deps/b/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("@rules_python//python:defs.bzl", "py_library")

py_library(
name = "b",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
Empty file.
9 changes: 9 additions & 0 deletions gazelle/python/testdata/clear_out_deps/c/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_python//python:defs.bzl", "py_library")

py_library(
name = "c",
srcs = ["__init__.py"],
pyi_deps = ["//a", "//b"],
visibility = ["//:__subpackages__"],
deps = ["//a", "//b"],
)
9 changes: 9 additions & 0 deletions gazelle/python/testdata/clear_out_deps/c/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_python//python:defs.bzl", "py_library")

py_library(
name = "c",
srcs = ["__init__.py"],
pyi_deps = ["//b"],
visibility = ["//:__subpackages__"],
deps = ["//a"],
)
6 changes: 6 additions & 0 deletions gazelle/python/testdata/clear_out_deps/c/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from typing import TYPE_CHECKING

import a

if TYPE_CHECKING:
import b
2 changes: 2 additions & 0 deletions gazelle/python/testdata/clear_out_deps/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

---