Merge pull request #52 from nat-n/fix_type_imports
Only import types from grpclib when type checking
This commit is contained in:
commit
0fe557bd3c
@ -27,7 +27,7 @@ from typing import (
|
|||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
)
|
)
|
||||||
|
|
||||||
import grpclib.client
|
|
||||||
import grpclib.const
|
import grpclib.const
|
||||||
import stringcase
|
import stringcase
|
||||||
|
|
||||||
@ -35,6 +35,8 @@ from .casing import safe_snake_case
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from grpclib._protocols import IProtoMessage
|
from grpclib._protocols import IProtoMessage
|
||||||
|
from grpclib.client import Channel
|
||||||
|
from grpclib.metadata import Deadline
|
||||||
|
|
||||||
if not (sys.version_info.major == 3 and sys.version_info.minor >= 7):
|
if not (sys.version_info.major == 3 and sys.version_info.minor >= 7):
|
||||||
# Apply backport of datetime.fromisoformat from 3.7
|
# Apply backport of datetime.fromisoformat from 3.7
|
||||||
@ -1073,10 +1075,10 @@ class ServiceStub(ABC):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
channel: grpclib.client.Channel,
|
channel: "Channel",
|
||||||
*,
|
*,
|
||||||
timeout: Optional[float] = None,
|
timeout: Optional[float] = None,
|
||||||
deadline: Optional[grpclib.metadata.Deadline] = None,
|
deadline: Optional["Deadline"] = None,
|
||||||
metadata: Optional[_MetadataLike] = None,
|
metadata: Optional[_MetadataLike] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
@ -1087,7 +1089,7 @@ class ServiceStub(ABC):
|
|||||||
def __resolve_request_kwargs(
|
def __resolve_request_kwargs(
|
||||||
self,
|
self,
|
||||||
timeout: Optional[float],
|
timeout: Optional[float],
|
||||||
deadline: Optional[grpclib.metadata.Deadline],
|
deadline: Optional["Deadline"],
|
||||||
metadata: Optional[_MetadataLike],
|
metadata: Optional[_MetadataLike],
|
||||||
):
|
):
|
||||||
return {
|
return {
|
||||||
@ -1103,7 +1105,7 @@ class ServiceStub(ABC):
|
|||||||
response_type: Type[T],
|
response_type: Type[T],
|
||||||
*,
|
*,
|
||||||
timeout: Optional[float] = None,
|
timeout: Optional[float] = None,
|
||||||
deadline: Optional[grpclib.metadata.Deadline] = None,
|
deadline: Optional["Deadline"] = None,
|
||||||
metadata: Optional[_MetadataLike] = None,
|
metadata: Optional[_MetadataLike] = None,
|
||||||
) -> T:
|
) -> T:
|
||||||
"""Make a unary request and return the response."""
|
"""Make a unary request and return the response."""
|
||||||
@ -1126,7 +1128,7 @@ class ServiceStub(ABC):
|
|||||||
response_type: Type[T],
|
response_type: Type[T],
|
||||||
*,
|
*,
|
||||||
timeout: Optional[float] = None,
|
timeout: Optional[float] = None,
|
||||||
deadline: Optional[grpclib.metadata.Deadline] = None,
|
deadline: Optional["Deadline"] = None,
|
||||||
metadata: Optional[_MetadataLike] = None,
|
metadata: Optional[_MetadataLike] = None,
|
||||||
) -> AsyncGenerator[T, None]:
|
) -> AsyncGenerator[T, None]:
|
||||||
"""Make a unary request and return the stream response iterator."""
|
"""Make a unary request and return the stream response iterator."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user