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:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							3d8c0cb713
						
					
				
				
					commit
					beafc812ff
				
			| @@ -664,6 +664,7 @@ class Message(ABC): | ||||
|         """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: | ||||
|             if field_cls.__args__ is not None: | ||||
|                 field_cls = field_cls.__args__[index] | ||||
|         return field_cls | ||||
|  | ||||
|   | ||||
| @@ -13,17 +13,17 @@ from typing import ( | ||||
|     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): | ||||
| @@ -59,7 +59,7 @@ class ServiceStub(ABC): | ||||
|     async def _unary_unary( | ||||
|         self, | ||||
|         route: str, | ||||
|         request: "IProtoMessage", | ||||
|         request: _MessageLike, | ||||
|         response_type: Type[T], | ||||
|         *, | ||||
|         timeout: Optional[float] = None, | ||||
| @@ -82,7 +82,7 @@ class ServiceStub(ABC): | ||||
|     async def _unary_stream( | ||||
|         self, | ||||
|         route: str, | ||||
|         request: "IProtoMessage", | ||||
|         request: _MessageLike, | ||||
|         response_type: Type[T], | ||||
|         *, | ||||
|         timeout: Optional[float] = None, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user