Skip to content

Commit

Permalink
Include AsyncIterator import for both clients and servers (#264)
Browse files Browse the repository at this point in the history
Co-authored-by: Robin Lambertz <github@roblab.la>
  • Loading branch information
lazytype and roblabla authored Nov 5, 2021
1 parent 421fdba commit c424b6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/betterproto/grpc/grpclib_server.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/betterproto/plugin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,9 @@ def __post_init__(self) -> None:
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
Expand Down

0 comments on commit c424b6f

Please sign in to comment.