Skip to content

Generate .pyi files in py_proto_library (#10366) #21567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

dws
Copy link
Contributor

@dws dws commented May 2, 2025

We here adjust py_proto_library to produce .pyi files along with the .py files it already generates. This achieves the same effect as the gRPC py_proto_library.

Per reviewer feedback, we here propagate the paths to the .pyi
files via the direct_pyi_files and transitive_pyi_files members
of PyInfo which are available starting in rules_python 1.1.0.

Since this means that the files are not automatically in the runfiles
of the py_proto_library, tooling to run mypy will need to be
adjusted to add what is needed from these provider fields to the
runfiles if that is what is wanted.

Closes #10366.

@jasonkuster
Copy link

+1; with grpc moving to using protobuf as the default for py_proto_library it regresses the creation of pyi files; this is the approach that repo takes and it would be very appreciated to get something like this merged.

@anandolee anandolee self-requested a review May 12, 2025 16:52
@anandolee anandolee added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 12, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 12, 2025
@dws dws marked this pull request as ready for review May 13, 2025 18:27
@dws
Copy link
Contributor Author

dws commented May 13, 2025

@anandolee Thanks for adding the tag! It looks like my PR passes CI, so I look forward to your review.

@mkruskal-google mkruskal-google added python bazel 🅰️ safe for tests Mark a commit as safe to run presubmits over labels May 19, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 19, 2025
@mkruskal-google mkruskal-google requested a review from haberman May 19, 2025 20:55
dws added a commit to dws/protobuf that referenced this pull request Jun 3, 2025
We here update the minimum required version of `rules_python` from
1.0.0 to 1.1.0 in order to enable using the new `direct_pyi_files`
and `transitive_pyi_files` members of `PyInfo` in protocolbuffers#21567.

Closes protocolbuffers#22078.
@dws dws force-pushed the py_proto_library-pyi branch 3 times, most recently from 3c5da60 to a4bbe43 Compare June 3, 2025 14:49
@mkruskal-google mkruskal-google added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jun 9, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jun 9, 2025
copybara-service bot pushed a commit that referenced this pull request Jun 9, 2025
We here update the minimum required version of `rules_python` from 1.0.0 to 1.1.0 in order to enable using the new `direct_pyi_files` and `transitive_pyi_files` members of `PyInfo` in #21567.

Closes #22078.

Closes #22079

COPYBARA_INTEGRATE_REVIEW=#22079 from dws:rules_python-1.1.0 7d0dc78
PiperOrigin-RevId: 769258504
@dws
Copy link
Contributor Author

dws commented Jun 9, 2025

@mkruskal-google Now that the rules_python bump has landed, please try another round of CI here.

@dws
Copy link
Contributor Author

dws commented Jun 16, 2025

@mkruskal-google ping?

1 similar comment
@dws
Copy link
Contributor Author

dws commented Jun 24, 2025

@mkruskal-google ping?

@dws
Copy link
Contributor Author

dws commented Jun 24, 2025

@anandolee perhaps you could enable a new round of CI testing? I think that's all that should be needed to land this now that it is approved.

@mkruskal-google mkruskal-google added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jul 1, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jul 1, 2025
dws added 2 commits July 1, 2025 11:31
We here adjust py_proto_library to produce `.pyi` files along with
the `.py` files it already generates.  This achieves the same effect
as the gRPC py_proto_library.

Closes protocolbuffers#10366.
Per reviewer feedback, we here propagate the paths to the `.pyi`
files via the `direct_pyi_files` and `transitive_pyi_files` members
of `PyInfo` which are available starting in `rules_python` 1.1.0.

Since this means that the files are not automatically in the runfiles
of the `py_proto_library`, tooling to run mypy will need to be
adjusted to add what is needed from these provider fields to the
runfiles if that is what is wanted.
@dws dws force-pushed the py_proto_library-pyi branch from a4bbe43 to 37fbdc0 Compare July 1, 2025 15:32
@mkruskal-google mkruskal-google added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jul 1, 2025
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Jul 1, 2025
@copybara-service copybara-service bot closed this in e3e56c7 Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support pyi_out in py_proto_library
4 participants