Skip to content

Commit c00ac82

Browse files
committed
chore: various cleanups to make google imports/patching easier
* Make py_library doc customizable. * Correct a typo checkers are spammy about * Add missing bzl_library. I would have expected our docgen to have also noticed this, but it must be picking it up from another transitive dependency, while the Google tests don't get that.
1 parent e682cd0 commit c00ac82

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

python/config_settings/BUILD.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,39 @@ string_flag(
3333
name = "precompile",
3434
build_setting_default = PrecompileFlag.AUTO,
3535
values = sorted(PrecompileFlag.__members__.values()),
36-
# NOTE: Only public because its an implicit dependency
36+
# NOTE: Only public because it's an implicit dependency
3737
visibility = ["//visibility:public"],
3838
)
3939

4040
string_flag(
4141
name = "precompile_source_retention",
4242
build_setting_default = PrecompileSourceRetentionFlag.KEEP_SOURCE,
4343
values = sorted(PrecompileSourceRetentionFlag.__members__.values()),
44-
# NOTE: Only public because its an implicit dependency
44+
# NOTE: Only public because it's an implicit dependency
4545
visibility = ["//visibility:public"],
4646
)
4747

4848
string_flag(
4949
name = "precompile_add_to_runfiles",
5050
build_setting_default = PrecompileAddToRunfilesFlag.ALWAYS,
5151
values = sorted(PrecompileAddToRunfilesFlag.__members__.values()),
52-
# NOTE: Only public because its an implicit dependency
52+
# NOTE: Only public because it's an implicit dependency
5353
visibility = ["//visibility:public"],
5454
)
5555

5656
string_flag(
5757
name = "pyc_collection",
5858
build_setting_default = PycCollectionFlag.DISABLED,
5959
values = sorted(PycCollectionFlag.__members__.values()),
60-
# NOTE: Only public because its an implicit dependency
60+
# NOTE: Only public because it's an implicit dependency
6161
visibility = ["//visibility:public"],
6262
)
6363

6464
string_flag(
6565
name = "bootstrap_impl",
6666
build_setting_default = BootstrapImplFlag.SYSTEM_PYTHON,
6767
values = sorted(BootstrapImplFlag.__members__.values()),
68-
# NOTE: Only public because its an implicit dependency
68+
# NOTE: Only public because it's an implicit dependency
6969
visibility = ["//visibility:public"],
7070
)
7171

python/private/common/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ bzl_library(
3535
"//python/private:enum_bzl",
3636
"//python/private:flags_bzl",
3737
"//python/private:reexports_bzl",
38+
"//python/private:rules_cc_srcs_bzl",
3839
"@bazel_skylib//rules:common_settings",
3940
],
4041
)

python/private/common/py_library.bzl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ def py_library_impl(ctx, *, semantics):
102102
create_output_group_info(py_info.transitive_sources, extra_groups = {}),
103103
]
104104

105+
_DEFAULT_PY_LIBRARY_DOC = """
106+
A library of Python code that can be depended upon.
107+
108+
Default outputs:
109+
* The input Python sources
110+
* The precompiled artifacts from the sources.
111+
112+
NOTE: Precompilation affects which of the default outputs are included in the
113+
resulting runfiles. See the precompile-related attributes and flags for
114+
more information.
115+
"""
116+
105117
def create_py_library_rule(*, attrs = {}, **kwargs):
106118
"""Creates a py_library rule.
107119
@@ -111,6 +123,9 @@ def create_py_library_rule(*, attrs = {}, **kwargs):
111123
Returns:
112124
A rule object
113125
"""
126+
127+
# Within Google, the doc attribute is overridden
128+
kwargs.setdefault("doc", _DEFAULT_PY_LIBRARY_DOC)
114129
return rule(
115130
attrs = dicts.add(LIBRARY_ATTRS, attrs),
116131
toolchains = [
@@ -120,16 +135,5 @@ def create_py_library_rule(*, attrs = {}, **kwargs):
120135
# TODO(b/253818097): fragments=py is only necessary so that
121136
# RequiredConfigFragmentsTest passes
122137
fragments = ["py"],
123-
doc = """
124-
A library of Python code that can be depended upon.
125-
126-
Default outputs:
127-
* The input Python sources
128-
* The precompiled artifacts from the sources.
129-
130-
NOTE: Precompilation affects which of the default outputs are included in the
131-
resulting runfiles. See the precompile-related attributes and flags for
132-
more information.
133-
""",
134138
**kwargs
135139
)

0 commit comments

Comments
 (0)