Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/grpc/_typing.py: 90%

21 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-06 06:03 +0000

1# Copyright 2022 gRPC authors. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14"""Common types for gRPC Sync API""" 

15 

16from typing import (TYPE_CHECKING, Any, Callable, Iterable, Iterator, Optional, 

17 Sequence, Tuple, TypeVar, Union) 

18 

19from grpc._cython import cygrpc 

20 

21if TYPE_CHECKING: 

22 from grpc import ServicerContext 

23 from grpc._server import _RPCState 

24 

25RequestType = TypeVar('RequestType') 

26ResponseType = TypeVar('ResponseType') 

27SerializingFunction = Callable[[Any], bytes] 

28DeserializingFunction = Callable[[bytes], Any] 

29MetadataType = Sequence[Tuple[str, Union[str, bytes]]] 

30ChannelArgumentType = Tuple[str, Any] 

31DoneCallbackType = Callable[[Any], None] 

32NullaryCallbackType = Callable[[], None] 

33RequestIterableType = Iterable[Any] 

34ResponseIterableType = Iterable[Any] 

35UserTag = Callable[[cygrpc.BaseEvent], bool] 

36IntegratedCallFactory = Callable[[ 

37 int, bytes, None, Optional[float], Optional[MetadataType], Optional[ 

38 cygrpc.CallCredentials], Sequence[Sequence[cygrpc. 

39 Operation]], UserTag, Any 

40], cygrpc.IntegratedCall] 

41ServerTagCallbackType = Tuple[Optional['_RPCState'], 

42 Sequence[NullaryCallbackType]] 

43ServerCallbackTag = Callable[[cygrpc.BaseEvent], ServerTagCallbackType] 

44ArityAgnosticMethodHandler = Union[ 

45 Callable[[RequestType, 'ServicerContext', Callable[[ResponseType], None]], 

46 ResponseType], 

47 Callable[[RequestType, 'ServicerContext', Callable[[ResponseType], None]], 

48 Iterator[ResponseType]], 

49 Callable[[ 

50 Iterator[RequestType], 'ServicerContext', Callable[[ResponseType], None] 

51 ], ResponseType], Callable[[ 

52 Iterator[RequestType], 'ServicerContext', Callable[[ResponseType], None] 

53 ], Iterator[ResponseType]], Callable[[RequestType, 'ServicerContext'], 

54 ResponseType], 

55 Callable[[RequestType, 'ServicerContext'], Iterator[ResponseType]], 

56 Callable[[Iterator[RequestType], 'ServicerContext'], 

57 ResponseType], Callable[[Iterator[RequestType], 'ServicerContext'], 

58 Iterator[ResponseType]]]