Add type stub generation for bazel rules#31791
Closed
kimmywork wants to merge 2 commits intogrpc:masterfrom
kimmywork:bazel_pyi_gen
Closed
Add type stub generation for bazel rules#31791kimmywork wants to merge 2 commits intogrpc:masterfrom kimmywork:bazel_pyi_gen
kimmywork wants to merge 2 commits intogrpc:masterfrom
kimmywork:bazel_pyi_gen
Conversation
|
|
Author
|
guess labels should be lang/Python and infra/Bazel. |
Contributor
|
@kimmywork Thanks for the contribution! This seems like a good change. Can you please add a test to this directory to make sure that there isn't a regression in this functionality? I'd imagine the test would do the following:
|
Collaborator
|
More than 30 days have passed since label "disposition/requires reporter action" was added. Closing this issue. Please feel free to re-open/create a new issue if this is still relevant. |
gnossen
pushed a commit
that referenced
this pull request
Jun 12, 2023
With some delay, this is a PR for #32564 (and previously #31791). I looked into adding a regular `py_test` for this change [as suggested](#31791 (comment)) but I am not aware of any effect that the presence of a .pyi stub file would have at runtime and where some sort of type-checking in a .py script would be affected. Stub files are only for use by type checkers & IDE's. I mean, something like this would work: ``` import helloworld_pb2 py_file = helloworld_pb2.__file__ pyi_file = py_file + 'i’ self.assertTrue(os.path.exists(pyi_file)) ``` But that seems really hacky to me. Instead I created a simple rule test for `py_proto_library` with Bazel Skylib which tests the declared outputs for an example `py_proto_library` target. Indirectly, this also tests that the declared output files are actually generated. Please let me know if this is sufficient.
mario-vimal
pushed a commit
to mario-vimal/grpc
that referenced
this pull request
Jun 15, 2023
With some delay, this is a PR for grpc#32564 (and previously grpc#31791). I looked into adding a regular `py_test` for this change [as suggested](grpc#31791 (comment)) but I am not aware of any effect that the presence of a .pyi stub file would have at runtime and where some sort of type-checking in a .py script would be affected. Stub files are only for use by type checkers & IDE's. I mean, something like this would work: ``` import helloworld_pb2 py_file = helloworld_pb2.__file__ pyi_file = py_file + 'i’ self.assertTrue(os.path.exists(pyi_file)) ``` But that seems really hacky to me. Instead I created a simple rule test for `py_proto_library` with Bazel Skylib which tests the declared outputs for an example `py_proto_library` target. Indirectly, this also tests that the declared output files are actually generated. Please let me know if this is sufficient.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added generating pyi stub option (
--pyi_out=...) inpy_proto_library.