You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use a gazelle rule with the starlark extension API to dynamically update rules to generate a type library
The standard gazelle:proto_plugin already supports using builtin:pyi to generate python type stubs from protobuf, but there isn't a good way out of the box to create a library out of these pyi files for consumption. The bazel-mypy-integration project has a mypy_stubs rule that is good for this purpose (https://github.com/bazel-contrib/bazel-mypy-integration/blob/main/rules.bzl) so we just need to glue these together.
I attempted to do it using these gazelle declarations:
I am trying to use a gazelle rule with the starlark extension API to dynamically update rules to generate a type library
The standard
gazelle:proto_plugin
already supports usingbuiltin:pyi
to generate python type stubs from protobuf, but there isn't a good way out of the box to create a library out of these pyi files for consumption. The bazel-mypy-integration project has amypy_stubs
rule that is good for this purpose (https://github.com/bazel-contrib/bazel-mypy-integration/blob/main/rules.bzl) so we just need to glue these together.I attempted to do it using these gazelle declarations:
and a
rules.star
like this:This works on the first run, but when a new proto is added, I noticed that while the "native" rules are updated, the starlark based one is not.
Full example here: https://github.com/avx-rchung/rules_proto/tree/starlark-example in the example/starlark_proto directory
Initial run to check everything is generated as expected:
check output in
example/starlark_proto/proto/BUILD.bazel
-- looks good.Add a new protobuf:
Note that c_pb2.* gets added to
proto_library
,proto_compile
,proto_py_library
but notmypy_stubs
If I delete the mypy_stub run and re-run gazelle and the rule is regenerated properly (including c_pb2)
The text was updated successfully, but these errors were encountered: