Skip to content

Commit 9ff6ab7

Browse files
docs: describe annotations attr of pip_parse (#1667)
My default expectation would be that the keys to the `annotations` dictionary passed to `pip_parse` would use the `normalize_name(...)` convention, as is used elsewhere in the API. However, this does not appear to be the case. I originally was going to file a bug, but maybe just documenting the current behavior is enough? For a minimal repro showing that this capitalization is indeed required, see https://github.com/bruno-digitbio/bug-rules-python-annotation-pyqt In that repo, ```bash $ bazel run //:test_has_comment $ tail $(bazel info output_base)/external/pip_pyqt6/BUILD.bazel $ tail $(bazel info output_base)/external/pip_wheel/BUILD.bazel ``` will both show `# A comment` at the bottom, as requested in the `WORKSPACE` file. However, if you first run ```bash $ bazel run //:requirements.update ``` then the auto-generated requirements file will use lowercase for the requirement specification, breaking the desired behavior. Please let me know if it makes more sense to just check in the docs, include this example (or something similar) as a small test, or something else. Apologies if I missed anything in the contribution guidelines!
1 parent bd0ca99 commit 9ff6ab7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

python/private/pypi/pip_repository.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ def _pip_repository_impl(rctx):
214214
pip_repository = repository_rule(
215215
attrs = dict(
216216
annotations = attr.string_dict(
217-
doc = "Optional annotations to apply to packages",
217+
doc = """\
218+
Optional annotations to apply to packages. Keys should be package names, with
219+
capitalization matching the input requirements file, and values should be
220+
generated using the `package_name` macro. For example usage, see [this WORKSPACE
221+
file](https://github.com/bazelbuild/rules_python/blob/main/examples/pip_repository_annotations/WORKSPACE).
222+
""",
218223
),
219224
_template = attr.label(
220225
default = ":requirements.bzl.tmpl.workspace",

0 commit comments

Comments
 (0)