fix: add explicit data attribute to compile_pip_requirements and forward it to the generated py_binary#3865
Conversation
…forward it to the generated `py_binary`
There was a problem hiding this comment.
Code Review
This pull request adds an explicit data attribute to the pip_compile macro and forwards it to the generated py_binary. The review feedback suggests defensively normalizing the data parameter to an empty list if it is falsy or None to prevent potential TypeError crashes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| native.filegroup( | ||
| name = name, | ||
| srcs = kwargs.pop("data", []) + [requirements_txt], | ||
| srcs = data + [requirements_txt], | ||
| visibility = visibility, | ||
| ) | ||
|
|
||
| data = [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints | ||
| data = data + [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints |
There was a problem hiding this comment.
To ensure defensive programming and prevent potential TypeError crashes if data is explicitly passed as None (which is a common pattern when programmatically constructing macro arguments), we should normalize data to an empty list if it is falsy/None. This is also consistent with how tags is handled later in this function (tags = tags or []).
| native.filegroup( | |
| name = name, | |
| srcs = kwargs.pop("data", []) + [requirements_txt], | |
| srcs = data + [requirements_txt], | |
| visibility = visibility, | |
| ) | |
| data = [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints | |
| data = data + [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints | |
| data = data or [] | |
| native.filegroup( | |
| name = name, | |
| srcs = data + [requirements_txt], | |
| visibility = visibility, | |
| ) | |
| data = data + [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints |
As stated in #3858, the
compile_pip_requirementsmacro accepts adataattribute, but this attribute is not forwarded to the internalpy_binarytarget generated for the.updatetarget.As a result, using
$(location :pip_cert)insideextra_argsfails during analysis because the generatedpy_binarydoes not declare:pip_certas a prerequisite.Before:
After:
Closes #3858