[Python] Remove Six dependency (#31264)
[Python][Remove Six] Remove Six dependency Part I
This commit is contained in:
parent
8230865a29
commit
42482060fc
|
|
@ -1,5 +1,6 @@
|
|||
# C/C++ build outputs
|
||||
.build/
|
||||
build/
|
||||
bins
|
||||
gens
|
||||
libs
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import time
|
|||
|
||||
import grpc
|
||||
from grpc._cython import cygrpc
|
||||
import six
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -55,8 +54,8 @@ CYGRPC_STATUS_CODE_TO_STATUS_CODE = {
|
|||
cygrpc.StatusCode.data_loss: grpc.StatusCode.DATA_LOSS,
|
||||
}
|
||||
STATUS_CODE_TO_CYGRPC_STATUS_CODE = {
|
||||
grpc_code: cygrpc_code for cygrpc_code, grpc_code in six.iteritems(
|
||||
CYGRPC_STATUS_CODE_TO_STATUS_CODE)
|
||||
grpc_code: cygrpc_code
|
||||
for cygrpc_code, grpc_code in CYGRPC_STATUS_CODE_TO_STATUS_CODE.items()
|
||||
}
|
||||
|
||||
MAXIMUM_WAIT_TIMEOUT = 0.1
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ from grpc import _common
|
|||
from grpc import _compression
|
||||
from grpc import _interceptor
|
||||
from grpc._cython import cygrpc
|
||||
import six
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -276,9 +275,11 @@ class _Context(grpc.ServicerContext):
|
|||
return id_key if id_key is None else _common.decode(id_key)
|
||||
|
||||
def auth_context(self):
|
||||
auth_context = cygrpc.auth_context(self._rpc_event.call)
|
||||
auth_context_dict = {} if auth_context is None else auth_context
|
||||
return {
|
||||
_common.decode(key): value for key, value in six.iteritems(
|
||||
cygrpc.auth_context(self._rpc_event.call))
|
||||
_common.decode(key): value
|
||||
for key, value in auth_context_dict.items()
|
||||
}
|
||||
|
||||
def set_compression(self, compression):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import time
|
|||
|
||||
import grpc
|
||||
from grpc import _common
|
||||
import six
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -48,7 +47,7 @@ class DictionaryGenericHandler(grpc.ServiceRpcHandler):
|
|||
self._name = service
|
||||
self._method_handlers = {
|
||||
_common.fully_qualified_method(service, method): method_handler
|
||||
for method, method_handler in six.iteritems(method_handlers)
|
||||
for method, method_handler in method_handlers.items()
|
||||
}
|
||||
|
||||
def service_name(self):
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import logging
|
|||
import unittest
|
||||
|
||||
import grpc
|
||||
import six
|
||||
|
||||
from tests.unit import _from_grpc_import_star
|
||||
|
||||
|
|
@ -92,8 +91,8 @@ class AllTest(unittest.TestCase):
|
|||
'insecure_server_credentials',
|
||||
)
|
||||
|
||||
six.assertCountEqual(self, expected_grpc_code_elements,
|
||||
_from_grpc_import_star.GRPC_ELEMENTS)
|
||||
self.assertCountEqual(expected_grpc_code_elements,
|
||||
_from_grpc_import_star.GRPC_ELEMENTS)
|
||||
|
||||
|
||||
class ChannelConnectivityTest(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import unittest
|
|||
import grpc
|
||||
from grpc import _channel
|
||||
from grpc.experimental import session_cache
|
||||
import six
|
||||
|
||||
from tests.unit import resources
|
||||
from tests.unit import test_common
|
||||
|
|
@ -142,7 +141,7 @@ class AuthContextTest(unittest.TestCase):
|
|||
|
||||
auth_data = pickle.loads(response)
|
||||
auth_ctx = auth_data[_AUTH_CTX]
|
||||
six.assertCountEqual(self, _CLIENT_IDS, auth_data[_ID])
|
||||
self.assertCountEqual(_CLIENT_IDS, auth_data[_ID])
|
||||
self.assertEqual('x509_subject_alternative_name', auth_data[_ID_KEY])
|
||||
self.assertSequenceEqual([b'ssl'], auth_ctx['transport_security_type'])
|
||||
self.assertSequenceEqual([b'*.test.google.com'],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import logging
|
|||
import unittest
|
||||
|
||||
import grpc
|
||||
import six
|
||||
|
||||
from tests.unit import test_common
|
||||
from tests.unit.framework.common import test_constants
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ import threading
|
|||
import time
|
||||
import unittest
|
||||
|
||||
import six
|
||||
|
||||
from tests.unit import _exit_scenarios
|
||||
|
||||
SCENARIO_FILE = os.path.abspath(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import time
|
|||
import unittest
|
||||
|
||||
import grpc
|
||||
import six
|
||||
|
||||
from tests.unit.framework.common import test_constants
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from concurrent import futures
|
|||
import threading
|
||||
|
||||
import grpc
|
||||
import six
|
||||
|
||||
INVOCATION_INITIAL_METADATA = (
|
||||
('0', 'abc'),
|
||||
|
|
@ -64,7 +63,7 @@ def metadata_transmitted(original_metadata, transmitted_metadata):
|
|||
for key, value in transmitted_metadata:
|
||||
transmitted[key].append(value)
|
||||
|
||||
for key, values in six.iteritems(original):
|
||||
for key, values in original.items():
|
||||
transmitted_values = transmitted[key]
|
||||
transmitted_iterator = iter(transmitted_values)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import unittest
|
|||
import grpc
|
||||
from grpc.experimental import aio
|
||||
from grpc.experimental import session_cache
|
||||
import six
|
||||
|
||||
from tests.unit import resources
|
||||
from tests_aio.unit._test_base import AioTestBase
|
||||
|
|
|
|||
Loading…
Reference in New Issue