Use str instead of Text

pull/21951/head
Lidi Zheng 5 years ago
parent d77a231c2a
commit 8701b18efb
  1. 6
      src/python/grpcio/grpc/experimental/aio/__init__.py
  2. 4
      src/python/grpcio/grpc/experimental/aio/_base_call.py
  3. 12
      src/python/grpcio/grpc/experimental/aio/_channel.py
  4. 4
      src/python/grpcio/grpc/experimental/aio/_interceptor.py
  5. 6
      src/python/grpcio/grpc/experimental/aio/_server.py
  6. 6
      src/python/grpcio/grpc/experimental/aio/_typing.py

@ -17,7 +17,7 @@ gRPC Async API objects may only be used on the thread on which they were
created. AsyncIO doesn't provide thread safety for most of its APIs. created. AsyncIO doesn't provide thread safety for most of its APIs.
""" """
from typing import Any, Optional, Sequence, Text, Tuple from typing import Any, Optional, Sequence, Tuple
import grpc import grpc
from grpc._cython.cygrpc import (EOF, AbortError, BaseError, UsageError, from grpc._cython.cygrpc import (EOF, AbortError, BaseError, UsageError,
@ -33,7 +33,7 @@ from ._typing import ChannelArgumentType
def insecure_channel( def insecure_channel(
target: Text, target: str,
options: Optional[ChannelArgumentType] = None, options: Optional[ChannelArgumentType] = None,
compression: Optional[grpc.Compression] = None, compression: Optional[grpc.Compression] = None,
interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]] = None): interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]] = None):
@ -56,7 +56,7 @@ def insecure_channel(
def secure_channel( def secure_channel(
target: Text, target: str,
credentials: grpc.ChannelCredentials, credentials: grpc.ChannelCredentials,
options: Optional[ChannelArgumentType] = None, options: Optional[ChannelArgumentType] = None,
compression: Optional[grpc.Compression] = None, compression: Optional[grpc.Compression] = None,

@ -19,7 +19,7 @@ RPC, e.g. cancellation.
""" """
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from typing import AsyncIterable, Awaitable, Generic, Optional, Text, Union from typing import AsyncIterable, Awaitable, Generic, Optional, Union
import grpc import grpc
@ -110,7 +110,7 @@ class Call(RpcContext, metaclass=ABCMeta):
""" """
@abstractmethod @abstractmethod
async def details(self) -> Text: async def details(self) -> str:
"""Accesses the details sent by the server. """Accesses the details sent by the server.
Returns: Returns:

@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
"""Invocation-side implementation of gRPC Asyncio Python.""" """Invocation-side implementation of gRPC Asyncio Python."""
import asyncio import asyncio
from typing import Any, AsyncIterable, Optional, Sequence, AbstractSet, Text from typing import Any, AsyncIterable, Optional, Sequence, AbstractSet
from weakref import WeakSet from weakref import WeakSet
import logging import logging
@ -321,7 +321,7 @@ class Channel:
_unary_unary_interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]] _unary_unary_interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]]
_ongoing_calls: _OngoingCalls _ongoing_calls: _OngoingCalls
def __init__(self, target: Text, options: ChannelArgumentType, def __init__(self, target: str, options: ChannelArgumentType,
credentials: Optional[grpc.ChannelCredentials], credentials: Optional[grpc.ChannelCredentials],
compression: Optional[grpc.Compression], compression: Optional[grpc.Compression],
interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]]): interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]]):
@ -470,7 +470,7 @@ class Channel:
def unary_unary( def unary_unary(
self, self,
method: Text, method: str,
request_serializer: Optional[SerializingFunction] = None, request_serializer: Optional[SerializingFunction] = None,
response_deserializer: Optional[DeserializingFunction] = None response_deserializer: Optional[DeserializingFunction] = None
) -> UnaryUnaryMultiCallable: ) -> UnaryUnaryMultiCallable:
@ -496,7 +496,7 @@ class Channel:
def unary_stream( def unary_stream(
self, self,
method: Text, method: str,
request_serializer: Optional[SerializingFunction] = None, request_serializer: Optional[SerializingFunction] = None,
response_deserializer: Optional[DeserializingFunction] = None response_deserializer: Optional[DeserializingFunction] = None
) -> UnaryStreamMultiCallable: ) -> UnaryStreamMultiCallable:
@ -507,7 +507,7 @@ class Channel:
def stream_unary( def stream_unary(
self, self,
method: Text, method: str,
request_serializer: Optional[SerializingFunction] = None, request_serializer: Optional[SerializingFunction] = None,
response_deserializer: Optional[DeserializingFunction] = None response_deserializer: Optional[DeserializingFunction] = None
) -> StreamUnaryMultiCallable: ) -> StreamUnaryMultiCallable:
@ -518,7 +518,7 @@ class Channel:
def stream_stream( def stream_stream(
self, self,
method: Text, method: str,
request_serializer: Optional[SerializingFunction] = None, request_serializer: Optional[SerializingFunction] = None,
response_deserializer: Optional[DeserializingFunction] = None response_deserializer: Optional[DeserializingFunction] = None
) -> StreamStreamMultiCallable: ) -> StreamStreamMultiCallable:

@ -16,7 +16,7 @@ import asyncio
import collections import collections
import functools import functools
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from typing import Callable, Optional, Iterator, Sequence, Text, Union from typing import Callable, Optional, Iterator, Sequence, Union
import grpc import grpc
from grpc._cython import cygrpc from grpc._cython import cygrpc
@ -36,7 +36,7 @@ class ClientCallDetails(
('method', 'timeout', 'metadata', 'credentials', 'wait_for_ready')), ('method', 'timeout', 'metadata', 'credentials', 'wait_for_ready')),
grpc.ClientCallDetails): grpc.ClientCallDetails):
method: Text method: str
timeout: Optional[float] timeout: Optional[float]
metadata: Optional[MetadataType] metadata: Optional[MetadataType]
credentials: Optional[grpc.CallCredentials] credentials: Optional[grpc.CallCredentials]

@ -15,7 +15,7 @@
import asyncio import asyncio
from concurrent.futures import Executor from concurrent.futures import Executor
from typing import Any, Optional, Sequence, Text from typing import Any, Optional, Sequence
import grpc import grpc
from grpc import _common, _compression from grpc import _common, _compression
@ -58,7 +58,7 @@ class Server:
""" """
self._server.add_generic_rpc_handlers(generic_rpc_handlers) self._server.add_generic_rpc_handlers(generic_rpc_handlers)
def add_insecure_port(self, address: Text) -> int: def add_insecure_port(self, address: str) -> int:
"""Opens an insecure port for accepting RPCs. """Opens an insecure port for accepting RPCs.
This method may only be called before starting the server. This method may only be called before starting the server.
@ -72,7 +72,7 @@ class Server:
""" """
return self._server.add_insecure_port(_common.encode(address)) return self._server.add_insecure_port(_common.encode(address))
def add_secure_port(self, address: Text, def add_secure_port(self, address: str,
server_credentials: grpc.ServerCredentials) -> int: server_credentials: grpc.ServerCredentials) -> int:
"""Opens a secure port for accepting RPCs. """Opens a secure port for accepting RPCs.

@ -13,15 +13,15 @@
# limitations under the License. # limitations under the License.
"""Common types for gRPC Async API""" """Common types for gRPC Async API"""
from typing import Any, AnyStr, Callable, Sequence, Text, Tuple, TypeVar from typing import Any, AnyStr, Callable, Sequence, Tuple, TypeVar
from grpc._cython.cygrpc import EOF from grpc._cython.cygrpc import EOF
RequestType = TypeVar('RequestType') RequestType = TypeVar('RequestType')
ResponseType = TypeVar('ResponseType') ResponseType = TypeVar('ResponseType')
SerializingFunction = Callable[[Any], bytes] SerializingFunction = Callable[[Any], bytes]
DeserializingFunction = Callable[[bytes], Any] DeserializingFunction = Callable[[bytes], Any]
MetadatumType = Tuple[Text, AnyStr] MetadatumType = Tuple[str, AnyStr]
MetadataType = Sequence[MetadatumType] MetadataType = Sequence[MetadatumType]
ChannelArgumentType = Sequence[Tuple[Text, Any]] ChannelArgumentType = Sequence[Tuple[str, Any]]
EOFType = type(EOF) EOFType = type(EOF)
DoneCallbackType = Callable[[Any], None] DoneCallbackType = Callable[[Any], None]

Loading…
Cancel
Save