From c424b6f8db78dd9e313802f0c12d9663b507ca0a Mon Sep 17 00:00:00 2001 From: lazytype Date: Fri, 5 Nov 2021 10:22:15 -0400 Subject: [PATCH] Include AsyncIterator import for both clients and servers (#264) Co-authored-by: Robin Lambertz --- src/betterproto/grpc/grpclib_server.py | 2 +- src/betterproto/plugin/models.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/betterproto/grpc/grpclib_server.py b/src/betterproto/grpc/grpclib_server.py index 59bc7d4..8b0bbd5 100644 --- a/src/betterproto/grpc/grpclib_server.py +++ b/src/betterproto/grpc/grpclib_server.py @@ -1,5 +1,5 @@ from abc import ABC -from collections import AsyncIterable +from collections.abc import AsyncIterable from typing import Callable, Any, Dict import grpclib diff --git a/src/betterproto/plugin/models.py b/src/betterproto/plugin/models.py index 36fa3b7..46dc9fb 100644 --- a/src/betterproto/plugin/models.py +++ b/src/betterproto/plugin/models.py @@ -653,7 +653,9 @@ class ServiceMethodCompiler(ProtoContentBase): self.output_file.typing_imports.add("AsyncIterable") self.output_file.typing_imports.add("Iterable") self.output_file.typing_imports.add("Union") - if self.server_streaming: + + # Required by both client and server + if self.client_streaming or self.server_streaming: self.output_file.typing_imports.add("AsyncIterator") super().__post_init__() # check for unset fields