Fix static type checking for grpclib client (#124)
* Fix static type checking in grpclib client * Fix python3.6 compatibility issue with dataclasses
This commit is contained in:
parent
3d8c0cb713
commit
beafc812ff
@ -664,7 +664,8 @@ class Message(ABC):
|
|||||||
"""Get the message class for a field from the type hints."""
|
"""Get the message class for a field from the type hints."""
|
||||||
field_cls = cls._type_hint(field.name)
|
field_cls = cls._type_hint(field.name)
|
||||||
if hasattr(field_cls, "__args__") and index >= 0:
|
if hasattr(field_cls, "__args__") and index >= 0:
|
||||||
field_cls = field_cls.__args__[index]
|
if field_cls.__args__ is not None:
|
||||||
|
field_cls = field_cls.__args__[index]
|
||||||
return field_cls
|
return field_cls
|
||||||
|
|
||||||
def _get_field_default(self, field_name):
|
def _get_field_default(self, field_name):
|
||||||
|
@ -13,17 +13,17 @@ from typing import (
|
|||||||
Type,
|
Type,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
from .._types import ST, T
|
from betterproto._types import ST, T
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from grpclib._typing import IProtoMessage
|
|
||||||
from grpclib.client import Channel
|
from grpclib.client import Channel
|
||||||
from grpclib.metadata import Deadline
|
from grpclib.metadata import Deadline
|
||||||
|
|
||||||
|
|
||||||
_Value = Union[str, bytes]
|
_Value = Union[str, bytes]
|
||||||
_MetadataLike = Union[Mapping[str, _Value], Collection[Tuple[str, _Value]]]
|
_MetadataLike = Union[Mapping[str, _Value], Collection[Tuple[str, _Value]]]
|
||||||
_MessageSource = Union[Iterable["IProtoMessage"], AsyncIterable["IProtoMessage"]]
|
_MessageLike = Union[T, ST]
|
||||||
|
_MessageSource = Union[Iterable[ST], AsyncIterable[ST]]
|
||||||
|
|
||||||
|
|
||||||
class ServiceStub(ABC):
|
class ServiceStub(ABC):
|
||||||
@ -59,7 +59,7 @@ class ServiceStub(ABC):
|
|||||||
async def _unary_unary(
|
async def _unary_unary(
|
||||||
self,
|
self,
|
||||||
route: str,
|
route: str,
|
||||||
request: "IProtoMessage",
|
request: _MessageLike,
|
||||||
response_type: Type[T],
|
response_type: Type[T],
|
||||||
*,
|
*,
|
||||||
timeout: Optional[float] = None,
|
timeout: Optional[float] = None,
|
||||||
@ -82,7 +82,7 @@ class ServiceStub(ABC):
|
|||||||
async def _unary_stream(
|
async def _unary_stream(
|
||||||
self,
|
self,
|
||||||
route: str,
|
route: str,
|
||||||
request: "IProtoMessage",
|
request: _MessageLike,
|
||||||
response_type: Type[T],
|
response_type: Type[T],
|
||||||
*,
|
*,
|
||||||
timeout: Optional[float] = None,
|
timeout: Optional[float] = None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user