Skip to content

Commit

Permalink
refactor: broaden visibility and use list() instead of keys() (#1704)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
rickeylev authored Jan 18, 2024
1 parent 6607a4a commit 711186f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/private/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

package(
default_visibility = ["//python:__subpackages__"],
default_visibility = ["//:__subpackages__"],
)

bzl_library(
Expand Down
6 changes: 3 additions & 3 deletions python/private/common/attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ COMMON_ATTR_NAMES = [
"testonly",
"toolchains",
"visibility",
] + COMMON_ATTRS.keys()
] + list(COMMON_ATTRS) # Use list() instead .keys() so it's valid Python

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

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

0 comments on commit 711186f

Please sign in to comment.