-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Import gRPC stubs from the grpc-stubs project #11204
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks for the PR! The stubtest checks currently fail: https://github.com/python/typeshed/actions/runs/7343810747/job/19994850116?pr=11204. This is the relevant output, I think:
I have no experience with grpc, so please correct me if my understanding is wrong: While these are the stubs for "gprc", what you actually install is the |
Thanks for getting back to me so quickly. I can see the failure but not sure what to do about it. I think you're right that it boils down to the |
I think just putting the stubs in a |
I haven't thought too deeply about it, but usually our stubtest checks install the package "x" when building the stubs in the "x" directory (the package will be called "types-x"). We could add a field like On a related note: It would make sense to me to also add (dummy) stubs for |
Putting it in |
This comment has been minimized.
This comment has been minimized.
Interesting, it looks like the typings in the Does typeshed play nice when part of a package is typed well and doesn't require stubs but another part of it isn't, and does? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yes! (at least it should, we don't have a lot of use-cases). Check the entry In the case the gRPC stubs are complete, but with modules purposefully left to the original package, you could set |
This comment has been minimized.
This comment has been minimized.
What is the remaining work to get this PR merged? |
Apologies @GrahamDennis, the longer it is since I've worked directly with gRPC, the less context remains in my head, and it has been a very long time now. I'm happy to keep trying to help get it over the line but I'll probably need someone to spell out what it is I need to do. I simply don't have the resources to reacquire the context needed to shepherd this over the line solo. |
No need to apologise, thanks for your effort. I was actually hoping a maintainer would respond with what they see as the requirements to merge |
This comment has been minimized.
This comment has been minimized.
I haven't investigated in details. But there's a few easy linting failures to fix. And the added test-cases aren't passing. Stubtest is also whining about apparent mismatches between the stubs and what's found at runtime. stubtest isn't always 100% correct and sometimes we do have to "cheat" a little bit, but those cases still need to be explicitly excluded and explained. |
I wouldn't worry too much about stubtest for this PR. We can simply silence its errors with allowlists (see any file named The test cases (in |
Co-authored-by: Avasam <samuel.06@hotmail.com>
Co-authored-by: Avasam <samuel.06@hotmail.com>
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: spark (https://github.com/apache/spark)
- python/pyspark/sql/connect/utils.py:72: error: Cannot find implementation or library stub for module named "grpc_status" [import-not-found]
- python/pyspark/sql/connect/client/reattach.py:30: error: Cannot find implementation or library stub for module named "grpc_status" [import-not-found]
- python/pyspark/sql/connect/plan.py:656: error: Unused "type: ignore" comment [unused-ignore]
- python/pyspark/sql/connect/client/core.py:59: error: Cannot find implementation or library stub for module named "grpc_status" [import-not-found]
jax (https://github.com/google/jax)
+ jax/experimental/jax2tf/examples/serving/model_server_request.py:18: error: Unused "type: ignore" comment [unused-ignore]
|
i took a look at the failing tests and made a pr to @shabbyrobe's branch: |
Following on from #10020, it seemed from that discussion that there was both desire from the issue tracker on the grpc-stubs project to submit these types to typeshed, and willingness on the part of typeshed to accept them, so here's my best first effort at making that happen. Happy to sign any CLA or copyright assignment you require.
This PR attempts to massage the stubs into a hopefully acceptable shape. The original types are functional, albeit gappy. I'm not sure what typeshed's current stance is on incomplete types but I do see a fair bit of prior art in there so I presume there's at least some leeway.
Full disclosure, there's an element of handoff here in my motivation as I'm not involved in any way with any project that uses gRPC and haven't been for nearly 5 years. I'm in no position to continue as maintainer of those stubs as it is; I hoped that by submitting to typeshed that might open up the maintenance pool somewhat. If that disqualifies this from inclusion that's fair; I can't quite tell if the original submitter of typings to typeshed is expected to continue to be responsible after inclusion, but I will need to archive and deprecate grpc-stubs regardless of the outcome, as I don't have enough mental context for working with gRPC any more and no proximate opportunity to revive it.
I found while preparing this PR that what was in the grpc-sttubs project was substantially misaligned with the typeshed conventions so I've worked through all of the lints and test failures that came up while migrating. I've also ported the tests over from the approach used in grpc-stubs to the approach used in typeshed.
There were a couple of other seemingly related things I wasn't sure about. The implementation package is called grpcio; should I have bundled up the
grpc*
folders into agrpcio
folder or are they ok where they are? Also, when usingrequires
in myMETADATA.toml
, what is the correct way to refer to the basegrpc
package? Pretty sure I'm doing this wrong as I see I'm getting a third party subtest failure.I am happy to spend a bit more time massaging this into a fit state for inclusion; I'm quite sure there's a fair bit that's still wrong about these (especially as they were intended to evolve alongside a project, but it just didn't pan out that way, and I ceased to be involved soon after their brisk creation, c'est la vie). They're a bit gappy in places and there were some outstanding issues on the original repo that I was not steeped enough in gRPC any more to be able to contextualise, let alone fix.
Please let me know whether it's worth proceeding and if there's anything that needs to be done, or if there's no pathway from this point and I should just archive the repo. Thank you.