rules_python
rules_python copied to clipboard
feat(gazelle): Add python_generate_pyi_srcs directive
Fixes #3354
This adds a new Gazelle directive python_generate_pyi_srcs
which accepts a boolean value true or false. It defaults
to false for backwards compatibility.
When true, the directive causes .pyi files, whose name matches
with a .py file found in srcs, to be added to the pyi_srcs
target attribute.
This helps with cases where manually-generated .pyi files are
present in the project and are needed for things such as rules_mypy.
Given the following files in a my_dir package:
BUILD.bazel
__init__.py
a.py
a.pyi
b.py
c.py
c.pyi
# gazelle:python_generate_pyi_srcs true will cause Gazelle to
generate:
py_library(
name = "my_dir",
srcs = [
"__init__.py",
"a.py",
"b.py",
"c.py",
],
pyi_srcs = [
"a.py",
"c.py",
],
)