• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 40833729979

29 Oct 2026 07:10AM UTC coverage: 93.016% (+0.05%) from 92.966%
40833729979

push

github

web-flow
Add buf as an alternate Python protobuf code generator (#23343)

Adds `buf generate` as an alternative to `protoc` for generating
code from Protobuf. buf is increasingly the standard Protobuf
toolchain, and it can fetch pinned plugins and dependencies from
the Buf Schema Registry rather than requiring them to be installed
locally. Plugins and output paths come from a `buf.gen.yaml`
template, rather than from Pants options.

Python opts in with `[python-protobuf].codegen_tool = "buf"`
(the default remains `protoc`). TypeScript, via the new
`pants.backend.experimental.codegen.protobuf.typescript` backend,
always uses buf.

In more detail:

- Python module mapping and runtime dependency inference follow
  the plugins named in the template.
- `remote:` BSR plugins must be pinned to a version and revision,
  so that codegen is reproducible. Pants fills in pins for common
  plugins, and `[buf].extra_plugin_pins` adds others.
- In-repo runnable targets can serve as `local:` codegen plugins
  (`[buf].codegen_plugins`) and as `buf lint` check plugins
  (`[buf].plugins`).
- `pants generate-lockfiles --resolve=buf` generates `buf.lock`,
  which is required when `buf.yaml` declares `deps:`.
- TypeScript `check` now runs codegen, so generated code is
  visible to `tsc`.

Partially addresses #20684.

---------

Co-authored-by: edelmanjm <jonathan.edelman@formlabs.com>

1055 of 1081 new or added lines in 28 files covered. (97.59%)

97604 of 104932 relevant lines covered (93.02%)

3.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.05
/src/python/pants/backend/codegen/protobuf/python/python_protobuf_module_mapper.py


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc