Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/betterproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ def _cls_for(cls, field: dataclasses.Field, index: int = 0) -> Type:
"""Get the message class for a field from the type hints."""
field_cls = cls._type_hint(field.name)
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

def _get_field_default(self, field_name):
Expand Down
10 changes: 5 additions & 5 deletions src/betterproto/grpc/grpclib_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
Type,
Union,
)
from .._types import ST, T
from betterproto._types import ST, T

if TYPE_CHECKING:
from grpclib._typing import IProtoMessage
from grpclib.client import Channel
from grpclib.metadata import Deadline


_Value = Union[str, bytes]
_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):
Expand Down Expand Up @@ -59,7 +59,7 @@ def __resolve_request_kwargs(
async def _unary_unary(
self,
route: str,
request: "IProtoMessage",
request: _MessageLike,
response_type: Type[T],
*,
timeout: Optional[float] = None,
Expand All @@ -82,7 +82,7 @@ async def _unary_unary(
async def _unary_stream(
self,
route: str,
request: "IProtoMessage",
request: _MessageLike,
response_type: Type[T],
*,
timeout: Optional[float] = None,
Expand Down