Skip to content

Commit ee5a00c

Browse files
committed
Revert "Fix static type checking for grpclib client (danielgtaylor#124)"
This reverts commit beafc81
1 parent 43c3c82 commit ee5a00c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/betterproto/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ def _cls_for(cls, field: dataclasses.Field, index: int = 0) -> Type:
662662
"""Get the message class for a field from the type hints."""
663663
field_cls = cls._type_hint(field.name)
664664
if hasattr(field_cls, "__args__") and index >= 0:
665-
if field_cls.__args__ is not None:
666-
field_cls = field_cls.__args__[index]
665+
field_cls = field_cls.__args__[index]
667666
return field_cls
668667

669668
def _get_field_default(self, field_name):

src/betterproto/grpc/grpclib_client.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
from .._types import ST, T
1919

2020
if TYPE_CHECKING:
21+
from grpclib._typing import IProtoMessage
2122
from grpclib.client import Channel
2223
from grpclib.metadata import Deadline
2324

2425

2526
_Value = Union[str, bytes]
2627
_MetadataLike = Union[Mapping[str, _Value], Collection[Tuple[str, _Value]]]
27-
_MessageLike = Union[T, ST]
28-
_MessageSource = Union[Iterable[ST], AsyncIterable[ST]]
28+
_MessageSource = Union[Iterable["IProtoMessage"], AsyncIterable["IProtoMessage"]]
2929

3030

3131
class ServiceStub(ABC):
@@ -61,7 +61,7 @@ def __resolve_request_kwargs(
6161
async def _unary_unary(
6262
self,
6363
route: str,
64-
request: _MessageLike,
64+
request: "IProtoMessage",
6565
response_type: Type[T],
6666
*,
6767
timeout: Optional[float] = None,
@@ -84,7 +84,7 @@ async def _unary_unary(
8484
async def _unary_stream(
8585
self,
8686
route: str,
87-
request: _MessageLike,
87+
request: "IProtoMessage",
8888
response_type: Type[T],
8989
*,
9090
timeout: Optional[float] = None,

0 commit comments

Comments
 (0)