-
Notifications
You must be signed in to change notification settings - Fork 21
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
No stubs for aio
#22
Comments
Thanks for reaching out! There are no concrete plans but there's definitely a desire. The last PR had to be reverted because it introduced a ton of problems I didn't have the time or inclination to work through. It was all autogenerated, didn't play nice with the rest of the package, and when I tried to write tests it showed up a lot of issues I didn't want to impose on package users. The PRs I get here are usually fine but this one caught me unawares and I just haven't come back to it yet. I think one of the things that would most help nudge me into action here would be if you had any simple, runnable examples of the ways you use the package lying around. That'd help me set up an environment (which if I'm honest, I find a bit of an "ugh" task) I can use to validate whether we're on the right track. The easier it is for me to run the examples without faffing around, the likelier it is that I'll get cracking on it. After the issues with the previous attempt, I probably won't just accept something wholesale again, I'd prefer to be involved, especially as there seemed to be a lot of messy overlap between the different coloured versions. I certainly won't be merging something that large without tests again, I've learned my lesson there! But as I'm not using the aio part of the package myself, that's really where those examples will be a huge help. |
A sample @pytest.mark.asyncio
async def test_grpc_response() -> None:
request = my_pb2.MyRequest(prop1="hello")
async with grpc.aio.insecure_channel("localhost:8000") as channel:
stub = my_pb2_grpc.MyServiceStub(channel)
response = await stub.GetResponse(request)
assert response Note that mypy also doesn't support the generated |
My understanding is that generating stubs for In order to generate reasonable stubs for def add_DummyServiceServicer_to_server(
servicer: DummyServiceServicer,
server: typing.Union[grpc.Server, grpc.aio.AioServer]) -> None: ... Hence I think this task is a pre-req for mypy-protobuf support. |
Tagging onto this. Over here I ran into an issue where when i use |
I think you are asking for a partial stub package. https://www.python.org/dev/peps/pep-0561/#partial-stub-packages If stub package includes the line https://github.com/shabbyrobe/grpc-stubs/blob/master/grpc-stubs/py.typed add one line to that file and that may be enough to fix your issue. |
There's no stubs for grpc aio, to my knowledge. As a workaround, you can do this:
|
@shabbyrobe would you be open to a PR for this if it works? |
Required since stubs for grpc.aio are not yet available See shabbyrobe/grpc-stubs#22 (comment)
Thanks to #22 (comment) for the tip, here's a workaround for pyright: In your source, import aio as import grpc.aio as aio to ensure we get a missing import error instead of a missing symbol error. Then in the [tool.pyright]
exclude = ["**/*_pb2*"]
# https://github.com/shabbyrobe/grpc-stubs/issues/22
reportMissingImports = "warning" But an even more targeted workaround is something like: # TODO remove ignore when stubs are availabe for grpc.aio
# See https://github.com/shabbyrobe/grpc-stubs/issues/22
import grpc.aio as aio # type: ignore UPDATE: doh! sorry for the commit spam! I shouldn't have linked this issue in the commit X| |
Required since stubs for grpc.aio are not yet available See shabbyrobe/grpc-stubs#22 (comment)
There are now incomplete subs for aio. Completing them is happening in #36. I think we can consider this issue complete. |
Is there any plans to include stubs for
grpc.aio
? I love this package but it doesn't seem to provide theaio
features. I am more than willing to help out if necessary. I also saw a discussion about this in #15, but not sure what's happening here.The text was updated successfully, but these errors were encountered: