Skip to content

Commit 711186f

Browse files
authored
refactor: broaden visibility and use list() instead of keys() (#1704)
This upstreams a couple trivial Google patches to make rules_python more compatible with some Google-internal changes. * Use list(dict) instead of dict.keys(). This is because some bzl files are run through a Python-based testing framework, and dict.keys() can't be concatenated to a list in Python 3. * Expand visibility to all of rules_python instead of just the python subdirectory. This makes some patches that use internals easier to maintain, but also makes the visiblity more in line with the rest of the project (where `//:__subpackages__` is used for convenience, as it avoids having to change visibility frequently, but still prevents public dependencies).
1 parent 6607a4a commit 711186f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

python/private/common/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1616

1717
package(
18-
default_visibility = ["//python:__subpackages__"],
18+
default_visibility = ["//:__subpackages__"],
1919
)
2020

2121
bzl_library(

python/private/common/attributes.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ COMMON_ATTR_NAMES = [
226226
"testonly",
227227
"toolchains",
228228
"visibility",
229-
] + COMMON_ATTRS.keys()
229+
] + list(COMMON_ATTRS) # Use list() instead .keys() so it's valid Python
230230

231231
# Attribute names common to all test=True rules
232232
TEST_ATTR_NAMES = COMMON_ATTR_NAMES + [
@@ -236,10 +236,10 @@ TEST_ATTR_NAMES = COMMON_ATTR_NAMES + [
236236
"flaky",
237237
"shard_count",
238238
"local",
239-
] + AGNOSTIC_TEST_ATTRS.keys()
239+
] + list(AGNOSTIC_TEST_ATTRS) # Use list() instead .keys() so it's valid Python
240240

241241
# Attribute names common to all executable=True rules
242242
BINARY_ATTR_NAMES = COMMON_ATTR_NAMES + [
243243
"args",
244244
"output_licenses", # NOTE: Common to all rules, but slated for removal
245-
] + AGNOSTIC_BINARY_ATTRS.keys()
245+
] + list(AGNOSTIC_BINARY_ATTRS) # Use list() instead .keys() so it's valid Python

0 commit comments

Comments
 (0)