| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks, see remarks below.
I'd normally be a little hesitant to add stubs for "experimental" APIs that may be removed in any minor release, but this particular function seems pretty stable (8+ yerars) and there seems to be ongoing work to maintain it / gevent compatibility, so adding it feels fine to me.
Sorry, something went wrong.
| from typing_extensions import assert_type | ||
|
|
||
| import grpc.experimental.gevent as grpc_gevent | ||
|
|
||
| assert_type(grpc_gevent.init_gevent(), None) |
There was a problem hiding this comment.
You can remove this file - test cases are only needed for weird and/or complicated cases that might regress in the future. This test basically repeats the signature (and a particularly trivial one at that :-)), so it isn't really necessary
Sorry, something went wrong.
| @@ -0,0 +1 @@ | |||
| from . import gevent as gevent | |||
There was a problem hiding this comment.
The runtime doesn't actually re-export gevent, so e.g. this fails:
$ uv run -w grpcio python3 -c 'import grpc.experimental; grpc.experimental.gevent'
Traceback (most recent call last):
File "<string>", line 1, in <module>
import grpc.experimental; grpc.experimental.gevent
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'grpc.experimental' has no attribute 'gevent'Type checkers understand submodule relationships, so we don't need to add anything here in order for them to understand that the gevent submodule exists.
| from . import gevent as gevent |
Sorry, something went wrong.
There was a problem hiding this comment.
I think you can just delete this file, since partial-stub = true, and no direct members of this module are being stubbed. But if that ends up not being the case, you need to add the following to account for the fact that not all public functions are part of the stub file:
def __getattr__(name: str): ... # incomplete moduleThe partial-stub marker in METADATA.toml only tells type checkers that whole modules are missing, not that modules that do exist might be incomplete. That's what the __getattr__ does. You may also need to add this module to pyrightconfig.stricter.json if not already covered
Sorry, something went wrong.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
|
@brianschubert Thanks for the detailed review and the helpful explanation. I’ve updated the PR based on your suggestions by removing the regression test and grpc/experimental/__init__.pyi, and keeping only grpc/experimental/gevent.pyi so the stub stays closer to the runtime behavior. I’ve also updated the PR description to match the current changes. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Changes
Add a minimal stub for grpc.experimental.gevent, which exists in the grpcio runtime package but is currently missing from the partial grpcio stubs.
This adds:
Follow-up to #15833.
Testing
Result: