From 8701b18efb6a8b4fe2d06dbeac3b6b4833f0365e Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Fri, 7 Feb 2020 10:40:26 -0800 Subject: [PATCH] Use str instead of Text --- src/python/grpcio/grpc/experimental/aio/__init__.py | 6 +++--- .../grpcio/grpc/experimental/aio/_base_call.py | 4 ++-- src/python/grpcio/grpc/experimental/aio/_channel.py | 12 ++++++------ .../grpcio/grpc/experimental/aio/_interceptor.py | 4 ++-- src/python/grpcio/grpc/experimental/aio/_server.py | 6 +++--- src/python/grpcio/grpc/experimental/aio/_typing.py | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/python/grpcio/grpc/experimental/aio/__init__.py b/src/python/grpcio/grpc/experimental/aio/__init__.py index db2feb5b2d4..d8d284780c1 100644 --- a/src/python/grpcio/grpc/experimental/aio/__init__.py +++ b/src/python/grpcio/grpc/experimental/aio/__init__.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. """ -from typing import Any, Optional, Sequence, Text, Tuple +from typing import Any, Optional, Sequence, Tuple import grpc from grpc._cython.cygrpc import (EOF, AbortError, BaseError, UsageError, @@ -33,7 +33,7 @@ from ._typing import ChannelArgumentType def insecure_channel( - target: Text, + target: str, options: Optional[ChannelArgumentType] = None, compression: Optional[grpc.Compression] = None, interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]] = None): @@ -56,7 +56,7 @@ def insecure_channel( def secure_channel( - target: Text, + target: str, credentials: grpc.ChannelCredentials, options: Optional[ChannelArgumentType] = None, compression: Optional[grpc.Compression] = None, diff --git a/src/python/grpcio/grpc/experimental/aio/_base_call.py b/src/python/grpcio/grpc/experimental/aio/_base_call.py index 318a1edfcc1..d116982aa79 100644 --- a/src/python/grpcio/grpc/experimental/aio/_base_call.py +++ b/src/python/grpcio/grpc/experimental/aio/_base_call.py @@ -19,7 +19,7 @@ RPC, e.g. cancellation. """ from abc import ABCMeta, abstractmethod -from typing import AsyncIterable, Awaitable, Generic, Optional, Text, Union +from typing import AsyncIterable, Awaitable, Generic, Optional, Union import grpc @@ -110,7 +110,7 @@ class Call(RpcContext, metaclass=ABCMeta): """ @abstractmethod - async def details(self) -> Text: + async def details(self) -> str: """Accesses the details sent by the server. Returns: diff --git a/src/python/grpcio/grpc/experimental/aio/_channel.py b/src/python/grpcio/grpc/experimental/aio/_channel.py index 7035dd6c35e..7201aabcc73 100644 --- a/src/python/grpcio/grpc/experimental/aio/_channel.py +++ b/src/python/grpcio/grpc/experimental/aio/_channel.py @@ -13,7 +13,7 @@ # limitations under the License. """Invocation-side implementation of gRPC Asyncio Python.""" import asyncio -from typing import Any, AsyncIterable, Optional, Sequence, AbstractSet, Text +from typing import Any, AsyncIterable, Optional, Sequence, AbstractSet from weakref import WeakSet import logging @@ -321,7 +321,7 @@ class Channel: _unary_unary_interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]] _ongoing_calls: _OngoingCalls - def __init__(self, target: Text, options: ChannelArgumentType, + def __init__(self, target: str, options: ChannelArgumentType, credentials: Optional[grpc.ChannelCredentials], compression: Optional[grpc.Compression], interceptors: Optional[Sequence[UnaryUnaryClientInterceptor]]): @@ -470,7 +470,7 @@ class Channel: def unary_unary( self, - method: Text, + method: str, request_serializer: Optional[SerializingFunction] = None, response_deserializer: Optional[DeserializingFunction] = None ) -> UnaryUnaryMultiCallable: @@ -496,7 +496,7 @@ class Channel: def unary_stream( self, - method: Text, + method: str, request_serializer: Optional[SerializingFunction] = None, response_deserializer: Optional[DeserializingFunction] = None ) -> UnaryStreamMultiCallable: @@ -507,7 +507,7 @@ class Channel: def stream_unary( self, - method: Text, + method: str, request_serializer: Optional[SerializingFunction] = None, response_deserializer: Optional[DeserializingFunction] = None ) -> StreamUnaryMultiCallable: @@ -518,7 +518,7 @@ class Channel: def stream_stream( self, - method: Text, + method: str, request_serializer: Optional[SerializingFunction] = None, response_deserializer: Optional[DeserializingFunction] = None ) -> StreamStreamMultiCallable: diff --git a/src/python/grpcio/grpc/experimental/aio/_interceptor.py b/src/python/grpcio/grpc/experimental/aio/_interceptor.py index 977fad71a4e..aca93fd468c 100644 --- a/src/python/grpcio/grpc/experimental/aio/_interceptor.py +++ b/src/python/grpcio/grpc/experimental/aio/_interceptor.py @@ -16,7 +16,7 @@ import asyncio import collections import functools from abc import ABCMeta, abstractmethod -from typing import Callable, Optional, Iterator, Sequence, Text, Union +from typing import Callable, Optional, Iterator, Sequence, Union import grpc from grpc._cython import cygrpc @@ -36,7 +36,7 @@ class ClientCallDetails( ('method', 'timeout', 'metadata', 'credentials', 'wait_for_ready')), grpc.ClientCallDetails): - method: Text + method: str timeout: Optional[float] metadata: Optional[MetadataType] credentials: Optional[grpc.CallCredentials] diff --git a/src/python/grpcio/grpc/experimental/aio/_server.py b/src/python/grpcio/grpc/experimental/aio/_server.py index 53762beaeaf..13ff381af09 100644 --- a/src/python/grpcio/grpc/experimental/aio/_server.py +++ b/src/python/grpcio/grpc/experimental/aio/_server.py @@ -15,7 +15,7 @@ import asyncio from concurrent.futures import Executor -from typing import Any, Optional, Sequence, Text +from typing import Any, Optional, Sequence import grpc from grpc import _common, _compression @@ -58,7 +58,7 @@ class Server: """ 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. 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)) - def add_secure_port(self, address: Text, + def add_secure_port(self, address: str, server_credentials: grpc.ServerCredentials) -> int: """Opens a secure port for accepting RPCs. diff --git a/src/python/grpcio/grpc/experimental/aio/_typing.py b/src/python/grpcio/grpc/experimental/aio/_typing.py index 15583754a63..ccd2f529936 100644 --- a/src/python/grpcio/grpc/experimental/aio/_typing.py +++ b/src/python/grpcio/grpc/experimental/aio/_typing.py @@ -13,15 +13,15 @@ # limitations under the License. """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 RequestType = TypeVar('RequestType') ResponseType = TypeVar('ResponseType') SerializingFunction = Callable[[Any], bytes] DeserializingFunction = Callable[[bytes], Any] -MetadatumType = Tuple[Text, AnyStr] +MetadatumType = Tuple[str, AnyStr] MetadataType = Sequence[MetadatumType] -ChannelArgumentType = Sequence[Tuple[Text, Any]] +ChannelArgumentType = Sequence[Tuple[str, Any]] EOFType = type(EOF) DoneCallbackType = Callable[[Any], None]