aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Leifur Halldor Asgeirsson <lasgeirsson@zerofail.com>2016-03-04 12:46:55 -0500
committerGravatar Leifur Halldor Asgeirsson <lasgeirsson@zerofail.com>2016-03-18 15:58:19 -0400
commit1abda1f02ba2412ae845f1427370c52cef821756 (patch)
tree34eaf15b1fbda1ad4fe941f31ab0f967d4e223db /src
parent4302be789d89703d48f033c44720f828765f1467 (diff)
specify metaclasses in a py3-compatible way
Diffstat (limited to 'src')
-rw-r--r--src/python/grpcio/grpc/_adapter/_types.py16
-rw-r--r--src/python/grpcio/grpc/_links/invocation.py7
-rw-r--r--src/python/grpcio/grpc/beta/interfaces.py22
-rw-r--r--src/python/grpcio/grpc/framework/alpha/_face_utilities.py10
-rw-r--r--src/python/grpcio/grpc/framework/alpha/exceptions.py7
-rw-r--r--src/python/grpcio/grpc/framework/alpha/interfaces.py31
-rw-r--r--src/python/grpcio/grpc/framework/base/_ingestion.py7
-rw-r--r--src/python/grpcio/grpc/framework/base/_interfaces.py25
-rw-r--r--src/python/grpcio/grpc/framework/base/_reception.py7
-rw-r--r--src/python/grpcio/grpc/framework/base/_transmission.py10
-rw-r--r--src/python/grpcio/grpc/framework/base/interfaces.py40
-rw-r--r--src/python/grpcio/grpc/framework/core/_end.py7
-rw-r--r--src/python/grpcio/grpc/framework/core/_ingestion.py7
-rw-r--r--src/python/grpcio/grpc/framework/core/_interfaces.py28
-rw-r--r--src/python/grpcio/grpc/framework/core/_termination.py5
-rw-r--r--src/python/grpcio/grpc/framework/face/exceptions.py7
-rw-r--r--src/python/grpcio/grpc/framework/face/interfaces.py37
-rw-r--r--src/python/grpcio/grpc/framework/foundation/activated.py6
-rw-r--r--src/python/grpcio/grpc/framework/foundation/callable_util.py7
-rw-r--r--src/python/grpcio/grpc/framework/foundation/future.py7
-rw-r--r--src/python/grpcio/grpc/framework/foundation/relay.py3
-rw-r--r--src/python/grpcio/grpc/framework/foundation/stream.py6
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/base/base.py25
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/face/face.py41
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/links/links.py7
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py7
-rw-r--r--src/python/grpcio/tests/unit/_links/_proto_scenarios.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_control.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_coverage.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/base_util.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/control.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/coverage.py12
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/interfaces.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/service.py40
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/test_case.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_control.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_service.py40
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py7
46 files changed, 268 insertions, 339 deletions
diff --git a/src/python/grpcio/grpc/_adapter/_types.py b/src/python/grpcio/grpc/_adapter/_types.py
index 3d5ab33d00..cd273646af 100644
--- a/src/python/grpcio/grpc/_adapter/_types.py
+++ b/src/python/grpcio/grpc/_adapter/_types.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@ import abc
import collections
import enum
+import six
+
from grpc._cython import cygrpc
@@ -247,8 +249,7 @@ class Event(collections.namedtuple(
"""
-class CompletionQueue:
- __metaclass__ = abc.ABCMeta
+class CompletionQueue(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self):
@@ -285,8 +286,7 @@ class CompletionQueue:
return None
-class Call:
- __metaclass__ = abc.ABCMeta
+class Call(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def start_batch(self, ops, tag):
@@ -334,8 +334,7 @@ class Call:
return None
-class Channel:
- __metaclass__ = abc.ABCMeta
+class Channel(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self, target, args, credentials=None):
@@ -399,8 +398,7 @@ class Channel:
return None
-class Server:
- __metaclass__ = abc.ABCMeta
+class Server(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self, completion_queue, args):
diff --git a/src/python/grpcio/grpc/_links/invocation.py b/src/python/grpcio/grpc/_links/invocation.py
index 5ca0a0ee60..672e3e4cc8 100644
--- a/src/python/grpcio/grpc/_links/invocation.py
+++ b/src/python/grpcio/grpc/_links/invocation.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,8 @@ import logging
import threading
import time
+import six
+
from grpc._adapter import _intermediary_low
from grpc._links import _constants
from grpc.beta import interfaces as beta_interfaces
@@ -372,12 +374,11 @@ class _Kernel(object):
pool.shutdown(wait=True)
-class InvocationLink(links.Link, activated.Activated):
+class InvocationLink(six.with_metaclass(abc.ABCMeta, links.Link, activated.Activated)):
"""A links.Link for use on the invocation-side of a gRPC connection.
Implementations of this interface are only valid for use when activated.
"""
- __metaclass__ = abc.ABCMeta
class _InvocationLink(InvocationLink):
diff --git a/src/python/grpcio/grpc/beta/interfaces.py b/src/python/grpcio/grpc/beta/interfaces.py
index 0663119163..e29a5b3379 100644
--- a/src/python/grpcio/grpc/beta/interfaces.py
+++ b/src/python/grpcio/grpc/beta/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
from grpc._adapter import _types
@@ -105,19 +107,17 @@ def grpc_call_options(disable_compression=False, credentials=None):
return GRPCCallOptions(disable_compression, None, credentials)
-class GRPCAuthMetadataContext(object):
+class GRPCAuthMetadataContext(six.with_metaclass(abc.ABCMeta)):
"""Provides information to call credentials metadata plugins.
Attributes:
service_url: A string URL of the service being called into.
method_name: A string of the fully qualified method name being called.
"""
- __metaclass__ = abc.ABCMeta
-class GRPCAuthMetadataPluginCallback(object):
+class GRPCAuthMetadataPluginCallback(six.with_metaclass(abc.ABCMeta)):
"""Callback object received by a metadata plugin."""
- __metaclass__ = abc.ABCMeta
def __call__(self, metadata, error):
"""Inform the gRPC runtime of the metadata to construct a CallCredentials.
@@ -130,10 +130,9 @@ class GRPCAuthMetadataPluginCallback(object):
raise NotImplementedError()
-class GRPCAuthMetadataPlugin(object):
+class GRPCAuthMetadataPlugin(six.with_metaclass(abc.ABCMeta)):
"""
"""
- __metaclass__ = abc.ABCMeta
def __call__(self, context, callback):
"""Invoke the plugin.
@@ -149,9 +148,8 @@ class GRPCAuthMetadataPlugin(object):
raise NotImplementedError()
-class GRPCServicerContext(object):
+class GRPCServicerContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code servicing RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def peer(self):
@@ -168,9 +166,8 @@ class GRPCServicerContext(object):
raise NotImplementedError()
-class GRPCInvocationContext(object):
+class GRPCInvocationContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code invoking RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def disable_next_request_compression(self):
@@ -178,9 +175,8 @@ class GRPCInvocationContext(object):
raise NotImplementedError()
-class Server(object):
+class Server(six.with_metaclass(abc.ABCMeta)):
"""Services RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_insecure_port(self, address):
diff --git a/src/python/grpcio/grpc/framework/alpha/_face_utilities.py b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
index fb0cfe426d..c97307df16 100644
--- a/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
+++ b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,8 @@
import abc
import collections
+import six
+
# face_interfaces is referenced from specification in this module.
from grpc.framework.common import cardinality
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
@@ -45,7 +47,7 @@ def _qualified_name(service_name, method_name):
# TODO(nathaniel): This structure is getting bloated; it could be shrunk if
# implementations._Stub used a generic rather than a dynamic underlying
# face-layer stub.
-class InvocationBreakdown(object):
+class InvocationBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of invocation-side views of RPC methods.
Attributes:
@@ -61,7 +63,6 @@ class InvocationBreakdown(object):
to callable behavior to be used deserializing response values for the
RPC.
"""
- __metaclass__ = abc.ABCMeta
class _EasyInvocationBreakdown(
@@ -73,7 +74,7 @@ class _EasyInvocationBreakdown(
pass
-class ServiceBreakdown(object):
+class ServiceBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of service-side views of RPC methods.
Attributes:
@@ -84,7 +85,6 @@ class ServiceBreakdown(object):
response_serializers: A dictionary from service-qualified RPC method name
to callable behavior to be used serializing response values for the RPC.
"""
- __metaclass__ = abc.ABCMeta
class _EasyServiceBreakdown(
diff --git a/src/python/grpcio/grpc/framework/alpha/exceptions.py b/src/python/grpcio/grpc/framework/alpha/exceptions.py
index 5234d3b91c..8ec260488e 100644
--- a/src/python/grpcio/grpc/framework/alpha/exceptions.py
+++ b/src/python/grpcio/grpc/framework/alpha/exceptions.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,12 @@
Only GRPC should instantiate and raise these exceptions.
"""
-
import abc
+import six
-class RpcError(Exception):
+class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by GRPC."""
- __metaclass__ = abc.ABCMeta
class CancellationError(RpcError):
diff --git a/src/python/grpcio/grpc/framework/alpha/interfaces.py b/src/python/grpcio/grpc/framework/alpha/interfaces.py
index 8380567c97..57e4b5e315 100644
--- a/src/python/grpcio/grpc/framework/alpha/interfaces.py
+++ b/src/python/grpcio/grpc/framework/alpha/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
# exceptions is referenced from specification in this module.
from grpc.framework.alpha import exceptions # pylint: disable=unused-import
from grpc.framework.foundation import activated
@@ -59,9 +61,8 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure'
-class CancellableIterator(object):
+class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __iter__(self):
@@ -79,9 +80,8 @@ class CancellableIterator(object):
raise NotImplementedError()
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -108,7 +108,7 @@ class RpcContext(object):
raise NotImplementedError()
-class UnaryUnarySyncAsync(object):
+class UnaryUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an
"async" method. Both calls take a request value and a numeric timeout.
@@ -117,7 +117,6 @@ class UnaryUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -147,7 +146,7 @@ class UnaryUnarySyncAsync(object):
raise NotImplementedError()
-class StreamUnarySyncAsync(object):
+class StreamUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an
"async" method. Both calls take an iterator of request values and a numeric
@@ -156,7 +155,6 @@ class StreamUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -191,9 +189,8 @@ class StreamUnarySyncAsync(object):
raise NotImplementedError()
-class RpcMethodDescription(object):
+class RpcMethodDescription(six.with_metaclass(abc.ABCMeta)):
"""A type for the common aspects of RPC method descriptions."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cardinality(self):
@@ -207,9 +204,8 @@ class RpcMethodDescription(object):
raise NotImplementedError()
-class RpcMethodInvocationDescription(RpcMethodDescription):
+class RpcMethodInvocationDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Invocation-side description of an RPC method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def serialize_request(self, request):
@@ -240,9 +236,8 @@ class RpcMethodInvocationDescription(RpcMethodDescription):
raise NotImplementedError()
-class RpcMethodServiceDescription(RpcMethodDescription):
+class RpcMethodServiceDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Service-side description of an RPC method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def deserialize_request(self, serialized_request):
@@ -345,7 +340,7 @@ class RpcMethodServiceDescription(RpcMethodDescription):
raise NotImplementedError()
-class Stub(object):
+class Stub(six.with_metaclass(abc.ABCMeta)):
"""A stub with callable RPC method names for attributes.
Instances of this type are context managers and only afford RPC invocation
@@ -369,12 +364,10 @@ class Stub(object):
exceptions.RpcError, exceptions.CancellationError,
and exceptions.ExpirationError.
"""
- __metaclass__ = abc.ABCMeta
-class Server(activated.Activated):
+class Server(six.with_metaclass(abc.ABCMeta, activated.Activated)):
"""A GRPC Server."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def port(self):
diff --git a/src/python/grpcio/grpc/framework/base/_ingestion.py b/src/python/grpcio/grpc/framework/base/_ingestion.py
index 06d5b92f0b..090cb158c9 100644
--- a/src/python/grpcio/grpc/framework/base/_ingestion.py
+++ b/src/python/grpcio/grpc/framework/base/_ingestion.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import collections
+import six
+
from grpc.framework.base import _constants
from grpc.framework.base import _interfaces
from grpc.framework.base import exceptions
@@ -72,9 +74,8 @@ class _EmptyConsumer(stream.Consumer):
"""See stream.Consumer.consume_and_terminate for specification."""
-class _ConsumerCreator(object):
+class _ConsumerCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different consumer-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def create_consumer(self, requirement):
diff --git a/src/python/grpcio/grpc/framework/base/_interfaces.py b/src/python/grpcio/grpc/framework/base/_interfaces.py
index d88cf76590..c0cc866cad 100644
--- a/src/python/grpcio/grpc/framework/base/_interfaces.py
+++ b/src/python/grpcio/grpc/framework/base/_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,14 +31,15 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.base import interfaces # pylint: disable=unused-import
from grpc.framework.foundation import stream
-class TerminationManager(object):
+class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
@@ -91,9 +92,8 @@ class TerminationManager(object):
raise NotImplementedError()
-class TransmissionManager(object):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def inmit(self, emission, complete):
@@ -117,9 +117,8 @@ class TransmissionManager(object):
raise NotImplementedError()
-class EmissionManager(stream.Consumer):
+class EmissionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager of values emitted by customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_ingestion_manager_and_expiration_manager(
@@ -166,9 +165,8 @@ class EmissionManager(stream.Consumer):
raise NotImplementedError()
-class IngestionManager(stream.Consumer):
+class IngestionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager responsible for executing customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
@@ -214,9 +212,8 @@ class IngestionManager(stream.Consumer):
raise NotImplementedError()
-class ExpirationManager(object):
+class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def change_timeout(self, timeout):
@@ -246,9 +243,8 @@ class ExpirationManager(object):
raise NotImplementedError()
-class ReceptionManager(object):
+class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def receive_ticket(self, ticket):
@@ -261,9 +257,8 @@ class ReceptionManager(object):
raise NotImplementedError()
-class CancellationManager(object):
+class CancellationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of operation cancellation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
diff --git a/src/python/grpcio/grpc/framework/base/_reception.py b/src/python/grpcio/grpc/framework/base/_reception.py
index dd428964f1..2bee3947f0 100644
--- a/src/python/grpcio/grpc/framework/base/_reception.py
+++ b/src/python/grpcio/grpc/framework/base/_reception.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.base import interfaces
from grpc.framework.base import _interfaces
@@ -40,9 +42,8 @@ _INITIAL_FRONT_TO_BACK_TICKET_KINDS = (
)
-class _Receiver(object):
+class _Receiver(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-handling behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def abort_if_abortive(self, ticket):
diff --git a/src/python/grpcio/grpc/framework/base/_transmission.py b/src/python/grpcio/grpc/framework/base/_transmission.py
index 6845129234..398faaf314 100644
--- a/src/python/grpcio/grpc/framework/base/_transmission.py
+++ b/src/python/grpcio/grpc/framework/base/_transmission.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.base import _constants
from grpc.framework.base import _interfaces
from grpc.framework.base import interfaces
@@ -77,9 +79,8 @@ _ABORTION_OUTCOME_TO_BACK_TO_FRONT_TICKET_KIND = {
}
-class _Ticketizer(object):
+class _Ticketizer(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def ticketize(self, operation_id, sequence_number, payload, complete):
@@ -187,9 +188,8 @@ class _BackTicketizer(_Ticketizer):
operation_id, sequence_number, kind, None)
-class TransmissionManager(_interfaces.TransmissionManager):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta, _interfaces.TransmissionManager)):
"""A _interfaces.TransmissionManager on which other managers may be set."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_ingestion_and_expiration_managers(
diff --git a/src/python/grpcio/grpc/framework/base/interfaces.py b/src/python/grpcio/grpc/framework/base/interfaces.py
index e22c10d975..7c58a23ce0 100644
--- a/src/python/grpcio/grpc/framework/base/interfaces.py
+++ b/src/python/grpcio/grpc/framework/base/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
# stream is referenced from specification in this module.
from grpc.framework.foundation import stream # pylint: disable=unused-import
@@ -50,13 +52,12 @@ class Outcome(enum.Enum):
SERVICED_FAILURE = 'serviced failure'
-class OperationContext(object):
+class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action.
Attributes:
trace_id: A uuid.UUID identifying a particular set of related operations.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -93,9 +94,8 @@ class OperationContext(object):
raise NotImplementedError()
-class Servicer(object):
+class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, name, context, output_consumer):
@@ -120,7 +120,7 @@ class Servicer(object):
raise NotImplementedError()
-class Operation(object):
+class Operation(six.with_metaclass(abc.ABCMeta)):
"""Representation of an in-progress operation.
Attributes:
@@ -129,7 +129,6 @@ class Operation(object):
context: An OperationContext affording information and action about the
operation.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
@@ -137,9 +136,8 @@ class Operation(object):
raise NotImplementedError()
-class ServicedIngestor(object):
+class ServicedIngestor(six.with_metaclass(abc.ABCMeta)):
"""Responsible for accepting the result of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def consumer(self, operation_context):
@@ -159,7 +157,7 @@ class ServicedIngestor(object):
raise NotImplementedError()
-class ServicedSubscription(object):
+class ServicedSubscription(six.with_metaclass(abc.ABCMeta)):
"""A sum type representing a serviced's interest in an operation.
Attributes:
@@ -167,7 +165,6 @@ class ServicedSubscription(object):
ingestor: A ServicedIngestor. Must be present if kind is Kind.FULL. Must
be None if kind is Kind.TERMINATION_ONLY or Kind.NONE.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
@@ -178,9 +175,8 @@ class ServicedSubscription(object):
NONE = 'none'
-class End(object):
+class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def operation_stats(self):
@@ -202,9 +198,8 @@ class End(object):
raise NotImplementedError()
-class Front(End):
+class Front(six.with_metaclass(abc.ABCMeta, End)):
"""Clientish objects that afford the invocation of operations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def operate(
@@ -228,9 +223,8 @@ class Front(End):
raise NotImplementedError()
-class Back(End):
+class Back(six.with_metaclass(abc.ABCMeta, End)):
"""Serverish objects that perform the work of operations."""
- __metaclass__ = abc.ABCMeta
class FrontToBackTicket(
@@ -315,9 +309,8 @@ class BackToFrontTicket(
TRANSMISSION_FAILURE = 'transmission failure'
-class ForeLink(object):
+class ForeLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts back-to-front tickets and emits front-to-back tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_back_to_front_ticket(self, ticket):
@@ -334,9 +327,8 @@ class ForeLink(object):
raise NotImplementedError()
-class RearLink(object):
+class RearLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts front-to-back tickets and emits back-to-front tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_front_to_back_ticket(self, ticket):
@@ -353,11 +345,9 @@ class RearLink(object):
raise NotImplementedError()
-class FrontLink(Front, ForeLink):
+class FrontLink(six.with_metaclass(abc.ABCMeta, Front, ForeLink)):
"""Clientish objects that operate by sending and receiving tickets."""
- __metaclass__ = abc.ABCMeta
-class BackLink(Back, RearLink):
+class BackLink(six.with_metaclass(abc.ABCMeta, Back, RearLink)):
"""Serverish objects that operate by sending and receiving tickets."""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/core/_end.py b/src/python/grpcio/grpc/framework/core/_end.py
index 9c615672aa..dc2f48589a 100644
--- a/src/python/grpcio/grpc/framework/core/_end.py
+++ b/src/python/grpcio/grpc/framework/core/_end.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import threading
import uuid
+import six
+
from grpc.framework.core import _operation
from grpc.framework.core import _utilities
from grpc.framework.foundation import callable_util
@@ -45,7 +47,7 @@ from grpc.framework.interfaces.links import utilities
_IDLE_ACTION_EXCEPTION_LOG_MESSAGE = 'Exception calling idle action!'
-class End(base.End, links.Link):
+class End(six.with_metaclass(abc.ABCMeta, base.End, links.Link)):
"""A bridge between base.End and links.Link.
Implementations of this interface translate arriving tickets into
@@ -53,7 +55,6 @@ class End(base.End, links.Link):
translate calls from application objects implementing base interfaces
into tickets sent to a joined link.
"""
- __metaclass__ = abc.ABCMeta
class _Cycle(object):
diff --git a/src/python/grpcio/grpc/framework/core/_ingestion.py b/src/python/grpcio/grpc/framework/core/_ingestion.py
index 4129a8ce43..1e1fd73ce4 100644
--- a/src/python/grpcio/grpc/framework/core/_ingestion.py
+++ b/src/python/grpcio/grpc/framework/core/_ingestion.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities
@@ -70,9 +72,8 @@ class _SubscriptionCreation(
ABANDONED = 'abandoned'
-class _SubscriptionCreator(object):
+class _SubscriptionCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of subscription-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def create(self, group, method):
diff --git a/src/python/grpcio/grpc/framework/core/_interfaces.py b/src/python/grpcio/grpc/framework/core/_interfaces.py
index ffa686b2b7..985e5e8550 100644
--- a/src/python/grpcio/grpc/framework/core/_interfaces.py
+++ b/src/python/grpcio/grpc/framework/core/_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,17 +31,18 @@
import abc
+import six
+
from grpc.framework.interfaces.base import base
-class TerminationManager(object):
+class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation.
Attributes:
outcome: None if the operation is active or a base.Outcome value if it has
terminated.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_callback(self, callback):
@@ -105,9 +106,8 @@ class TerminationManager(object):
raise NotImplementedError()
-class TransmissionManager(object):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def kick_off(
@@ -171,9 +171,8 @@ class TransmissionManager(object):
raise NotImplementedError()
-class ExpirationManager(object):
+class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def change_timeout(self, timeout):
@@ -203,9 +202,8 @@ class ExpirationManager(object):
raise NotImplementedError()
-class ProtocolManager(object):
+class ProtocolManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of protocol-specific values passing through an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_protocol_receiver(self, protocol_receiver):
@@ -228,9 +226,8 @@ class ProtocolManager(object):
raise NotImplementedError()
-class EmissionManager(base.Operator):
+class EmissionManager(six.with_metaclass(abc.ABCMeta, base.Operator)):
"""A manager of values emitted by customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def advance(
@@ -254,14 +251,13 @@ class EmissionManager(base.Operator):
raise NotImplementedError()
-class IngestionManager(object):
+class IngestionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for executing customer code.
This name of this manager comes from its responsibility to pass successive
values from the other side of the operation into the code of the local
customer.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_group_and_method(self, group, method):
@@ -294,9 +290,8 @@ class IngestionManager(object):
raise NotImplementedError()
-class ReceptionManager(object):
+class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def receive_ticket(self, ticket):
@@ -308,7 +303,7 @@ class ReceptionManager(object):
raise NotImplementedError()
-class Operation(object):
+class Operation(six.with_metaclass(abc.ABCMeta)):
"""An ongoing operation.
Attributes:
@@ -316,7 +311,6 @@ class Operation(object):
operator: A base.Operator object for the operation for use by the customer
of the operation.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def handle_ticket(self, ticket):
diff --git a/src/python/grpcio/grpc/framework/core/_termination.py b/src/python/grpcio/grpc/framework/core/_termination.py
index 364158b2b8..e8c4ec60a3 100644
--- a/src/python/grpcio/grpc/framework/core/_termination.py
+++ b/src/python/grpcio/grpc/framework/core/_termination.py
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities
@@ -50,9 +52,8 @@ def _service_completion_predicate(
return transmission_complete and ingestion_complete
-class TerminationManager(_interfaces.TerminationManager):
+class TerminationManager(six.with_metaclass(abc.ABCMeta, _interfaces.TerminationManager)):
"""A _interfaces.TransmissionManager on which another manager may be set."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
diff --git a/src/python/grpcio/grpc/framework/face/exceptions.py b/src/python/grpcio/grpc/framework/face/exceptions.py
index f112df70bc..c272ac75ab 100644
--- a/src/python/grpcio/grpc/framework/face/exceptions.py
+++ b/src/python/grpcio/grpc/framework/face/exceptions.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
class NoSuchMethodError(Exception):
"""Raised by customer code to indicate an unrecognized RPC method name.
@@ -49,12 +51,11 @@ class NoSuchMethodError(Exception):
self.name = name
-class RpcError(Exception):
+class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by the Face layer.
Only RPC Framework should instantiate and raise these exceptions.
"""
- __metaclass__ = abc.ABCMeta
class CancellationError(RpcError):
diff --git a/src/python/grpcio/grpc/framework/face/interfaces.py b/src/python/grpcio/grpc/framework/face/interfaces.py
index b7cc4c1169..1b9a674be0 100644
--- a/src/python/grpcio/grpc/framework/face/interfaces.py
+++ b/src/python/grpcio/grpc/framework/face/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
# cardinality, style, exceptions, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
@@ -52,9 +54,8 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure'
-class CancellableIterator(object):
+class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __iter__(self):
@@ -72,9 +73,8 @@ class CancellableIterator(object):
raise NotImplementedError()
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -103,13 +103,12 @@ class RpcContext(object):
raise NotImplementedError()
-class Call(object):
+class Call(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side representation of an RPC.
Attributes:
context: An RpcContext affording information about the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
@@ -117,9 +116,8 @@ class Call(object):
raise NotImplementedError()
-class UnaryUnaryMultiCallable(object):
+class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -171,9 +169,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError()
-class UnaryStreamMultiCallable(object):
+class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -209,9 +206,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError()
-class StreamUnaryMultiCallable(object):
+class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -264,9 +260,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError()
-class StreamStreamMultiCallable(object):
+class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -302,7 +297,7 @@ l Args:
raise NotImplementedError()
-class MethodImplementation(object):
+class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes an RPC method implementation.
Attributes:
@@ -347,12 +342,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT.
"""
- __metaclass__ = abc.ABCMeta
-class MultiMethodImplementation(object):
+class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many RPC methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, name, response_consumer, context):
@@ -381,9 +374,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError()
-class GenericStub(object):
+class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC methods to callers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking_value_in_value_out(self, name, request, timeout):
@@ -622,7 +614,7 @@ class GenericStub(object):
raise NotImplementedError()
-class DynamicStub(object):
+class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""A stub with RPC-method-bound multi-callable attributes.
Instances of this type responsd to attribute access as follows: if the
@@ -637,4 +629,3 @@ class DynamicStub(object):
the attribute will be a StreamStreamMultiCallable with which to invoke the
RPC method.
"""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/foundation/activated.py b/src/python/grpcio/grpc/framework/foundation/activated.py
index 426a71c705..9b49b6363c 100644
--- a/src/python/grpcio/grpc/framework/foundation/activated.py
+++ b/src/python/grpcio/grpc/framework/foundation/activated.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,14 +31,14 @@
import abc
+import six
-class Activated(object):
+class Activated(six.with_metaclass(abc.ABCMeta)):
"""Interface for objects that may be started and stopped.
Values implementing this type must also implement the context manager
protocol.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __enter__(self):
diff --git a/src/python/grpcio/grpc/framework/foundation/callable_util.py b/src/python/grpcio/grpc/framework/foundation/callable_util.py
index 32b0751a01..e0a4cab738 100644
--- a/src/python/grpcio/grpc/framework/foundation/callable_util.py
+++ b/src/python/grpcio/grpc/framework/foundation/callable_util.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -35,8 +35,10 @@ import enum
import functools
import logging
+import six
-class Outcome(object):
+
+class Outcome(six.with_metaclass(abc.ABCMeta)):
"""A sum type describing the outcome of some call.
Attributes:
@@ -47,7 +49,6 @@ class Outcome(object):
exception: The exception raised by the call. Must be present if kind is
Kind.RAISED.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
diff --git a/src/python/grpcio/grpc/framework/foundation/future.py b/src/python/grpcio/grpc/framework/foundation/future.py
index bfc16fc1ea..bb8ee3ad87 100644
--- a/src/python/grpcio/grpc/framework/foundation/future.py
+++ b/src/python/grpcio/grpc/framework/foundation/future.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -49,6 +49,8 @@ built-in-but-only-in-3.3-and-later TimeoutError.
import abc
+import six
+
class TimeoutError(Exception):
"""Indicates that a particular call timed out."""
@@ -58,13 +60,12 @@ class CancelledError(Exception):
"""Indicates that the computation underlying a Future was cancelled."""
-class Future(object):
+class Future(six.with_metaclass(abc.ABCMeta)):
"""A representation of a computation in another control flow.
Computations represented by a Future may be yet to be begun, may be ongoing,
or may have already completed.
"""
- __metaclass__ = abc.ABCMeta
# NOTE(nathaniel): This isn't the return type that I would want to have if it
# were up to me. Were this interface being written from scratch, the return
diff --git a/src/python/grpcio/grpc/framework/foundation/relay.py b/src/python/grpcio/grpc/framework/foundation/relay.py
index 9c23946552..ff4e2275ae 100644
--- a/src/python/grpcio/grpc/framework/foundation/relay.py
+++ b/src/python/grpcio/grpc/framework/foundation/relay.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,6 @@ class Relay(object):
would be no reason to use an implementation of this interface instead of a
thread pool.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_value(self, value):
diff --git a/src/python/grpcio/grpc/framework/foundation/stream.py b/src/python/grpcio/grpc/framework/foundation/stream.py
index 75c0cf145b..32a2e52aed 100644
--- a/src/python/grpcio/grpc/framework/foundation/stream.py
+++ b/src/python/grpcio/grpc/framework/foundation/stream.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,10 +31,10 @@
import abc
+import six
-class Consumer(object):
+class Consumer(six.with_metaclass(abc.ABCMeta)):
"""Interface for consumers of finite streams of values or objects."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def consume(self, value):
diff --git a/src/python/grpcio/grpc/framework/interfaces/base/base.py b/src/python/grpcio/grpc/framework/interfaces/base/base.py
index a1e70be5e8..69be37e7ab 100644
--- a/src/python/grpcio/grpc/framework/interfaces/base/base.py
+++ b/src/python/grpcio/grpc/framework/interfaces/base/base.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -42,6 +42,8 @@ import abc
import enum
import threading # pylint: disable=unused-import
+import six
+
# abandonment is referenced from specification in this module.
from grpc.framework.foundation import abandonment # pylint: disable=unused-import
@@ -95,7 +97,7 @@ class Outcome(object):
REMOTE_FAILURE = 'remote failure'
-class Completion(object):
+class Completion(six.with_metaclass(abc.ABCMeta)):
"""An aggregate of the values exchanged upon operation completion.
Attributes:
@@ -103,12 +105,10 @@ class Completion(object):
code: A code value for the operation.
message: A message value for the operation.
"""
- __metaclass__ = abc.ABCMeta
-class OperationContext(object):
+class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def outcome(self):
@@ -162,9 +162,8 @@ class OperationContext(object):
raise NotImplementedError()
-class Operator(object):
+class Operator(six.with_metaclass(abc.ABCMeta)):
"""An interface through which to participate in an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def advance(
@@ -184,9 +183,8 @@ class Operator(object):
"""
raise NotImplementedError()
-class ProtocolReceiver(object):
+class ProtocolReceiver(six.with_metaclass(abc.ABCMeta)):
"""A means of receiving protocol values during an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def context(self, protocol_context):
@@ -198,7 +196,7 @@ class ProtocolReceiver(object):
raise NotImplementedError()
-class Subscription(object):
+class Subscription(six.with_metaclass(abc.ABCMeta)):
"""Describes customer code's interest in values from the other side.
Attributes:
@@ -216,7 +214,6 @@ class Subscription(object):
become available during the operation. Must be non-None if kind is
Kind.FULL.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
@@ -226,9 +223,8 @@ class Subscription(object):
FULL = 'full'
-class Servicer(object):
+class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, group, method, context, output_operator):
@@ -255,9 +251,8 @@ class Servicer(object):
raise NotImplementedError()
-class End(object):
+class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def start(self):
diff --git a/src/python/grpcio/grpc/framework/interfaces/face/face.py b/src/python/grpcio/grpc/framework/interfaces/face/face.py
index 404c3a7937..b994acecac 100644
--- a/src/python/grpcio/grpc/framework/interfaces/face/face.py
+++ b/src/python/grpcio/grpc/framework/interfaces/face/face.py
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
# cardinality, style, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
@@ -96,7 +98,7 @@ class Abortion(
REMOTE_FAILURE = 'remote failure'
-class AbortionError(Exception):
+class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for exceptions indicating RPC abortion.
initial_metadata: The initial metadata from the other side of the RPC or
@@ -108,7 +110,6 @@ class AbortionError(Exception):
details: The details value from the other side of the RPC or None if no
details value was received.
"""
- __metaclass__ = abc.ABCMeta
def __init__(self, initial_metadata, terminal_metadata, code, details):
super(AbortionError, self).__init__()
@@ -150,9 +151,8 @@ class RemoteError(AbortionError):
"""Indicates that an RPC has terminated due to a remote defect."""
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -199,9 +199,8 @@ class RpcContext(object):
raise NotImplementedError()
-class Call(RpcContext):
+class Call(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""Invocation-side utility object for an RPC."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self):
@@ -256,9 +255,8 @@ class Call(RpcContext):
raise NotImplementedError()
-class ServicerContext(RpcContext):
+class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""A context object passed to method implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def invocation_metadata(self):
@@ -326,9 +324,8 @@ class ServicerContext(RpcContext):
raise NotImplementedError()
-class ResponseReceiver(object):
+class ResponseReceiver(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side object used to accept the output of an RPC."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self, initial_metadata):
@@ -362,9 +359,8 @@ class ResponseReceiver(object):
raise NotImplementedError()
-class UnaryUnaryMultiCallable(object):
+class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -434,9 +430,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError()
-class UnaryStreamMultiCallable(object):
+class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout, metadata=None, protocol_options=None):
@@ -480,9 +475,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError()
-class StreamUnaryMultiCallable(object):
+class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -553,9 +547,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError()
-class StreamStreamMultiCallable(object):
+class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -600,7 +593,7 @@ class StreamStreamMultiCallable(object):
raise NotImplementedError()
-class MethodImplementation(object):
+class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes a method implementation.
Attributes:
@@ -643,12 +636,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT.
"""
- __metaclass__ = abc.ABCMeta
-class MultiMethodImplementation(object):
+class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, group, method, response_consumer, context):
@@ -678,9 +669,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError()
-class GenericStub(object):
+class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via generic methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking_unary_unary(
@@ -977,7 +967,7 @@ class GenericStub(object):
raise NotImplementedError()
-class DynamicStub(object):
+class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via attributes corresponding to afforded methods.
Instances of this type may be scoped to a single group so that attribute
@@ -993,4 +983,3 @@ class DynamicStub(object):
if the requested attribute is the name of a stream-stream method, the value of
the attribute will be a StreamStreamMultiCallable with which to invoke an RPC.
"""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/interfaces/links/links.py b/src/python/grpcio/grpc/framework/interfaces/links/links.py
index 24f0e3b354..808167935f 100644
--- a/src/python/grpcio/grpc/framework/interfaces/links/links.py
+++ b/src/python/grpcio/grpc/framework/interfaces/links/links.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
class Protocol(collections.namedtuple('Protocol', ('kind', 'value',))):
"""A sum type for handles to a system that transmits tickets.
@@ -123,9 +125,8 @@ class Ticket(
REMOTE_FAILURE = 'remote failure'
-class Link(object):
+class Link(six.with_metaclass(abc.ABCMeta)):
"""Accepts and emits tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_ticket(self, ticket):
diff --git a/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
index f55a7a23ea..c9f36636b5 100644
--- a/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,12 +32,13 @@
import abc
import threading
+import six
+
from tests.unit._junkdrawer import math_pb2
-class ProtoScenario(object):
+class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def method(self):
diff --git a/src/python/grpcio/tests/unit/_links/_proto_scenarios.py b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
index f69ff51b16..acd4891390 100644
--- a/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,13 +32,14 @@
import abc
import threading
+import six
+
from tests.unit._junkdrawer import math_pb2
from tests.unit.framework.common import test_constants
-class ProtoScenario(object):
+class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group_and_method(self):
diff --git a/src/python/grpcio/tests/unit/framework/common/test_control.py b/src/python/grpcio/tests/unit/framework/common/test_control.py
index 8d6eba5c2c..0387668b11 100644
--- a/src/python/grpcio/tests/unit/framework/common/test_control.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import contextlib
import threading
+import six
+
class Defect(Exception):
"""Simulates a programming defect raised into in a system under test.
@@ -42,7 +44,7 @@ class Defect(Exception):
"""
-class Control(object):
+class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method
@@ -51,8 +53,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def control(self):
"""Potentially does anything."""
diff --git a/src/python/grpcio/tests/unit/framework/common/test_coverage.py b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
index a7ed3582c4..184621fb5c 100644
--- a/src/python/grpcio/tests/unit/framework/common/test_coverage.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,14 @@
import abc
+import six
+
# This code is designed for use with the unittest module.
# pylint: disable=invalid-name
-class Coverage(object):
+class Coverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self):
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
index 1df1529b27..60ab5bc0fe 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.base import util as _base_util
from grpc.framework.base import implementations
@@ -43,7 +45,7 @@ _POOL_SIZE_LIMIT = 5
_MAXIMUM_TIMEOUT = 90
-class LinkedPair(object):
+class LinkedPair(six.with_metaclass(abc.ABCMeta)):
"""A Front and Back that are linked to one another.
Attributes:
@@ -51,8 +53,6 @@ class LinkedPair(object):
back: An interfaces.Back.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def shut_down(self):
"""Shuts down this object and releases its resources."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
index 0613516421..2fc67f6292 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.face import exceptions
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import control
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class BlockingInvocationInlineServiceTestCase(
- test_case.FaceTestCase, coverage.BlockingCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.BlockingCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/control.py b/src/python/grpcio/tests/unit/framework/face/testing/control.py
index 3960c4e649..0d40331e19 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/control.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,8 +33,10 @@ import abc
import contextlib
import threading
+import six
-class Control(object):
+
+class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method
@@ -43,8 +45,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def control(self):
"""Potentially does anything."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
index f3aca113fe..9f5381069d 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,15 +31,15 @@
import abc
+import six
+
# These classes are only valid when inherited by unittest.TestCases.
# pylint: disable=invalid-name
-class BlockingCoverage(object):
+class BlockingCoverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage for blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self):
raise NotImplementedError()
@@ -93,11 +93,9 @@ class BlockingCoverage(object):
raise NotImplementedError()
-class FullCoverage(BlockingCoverage):
+class FullCoverage(six.with_metaclass(abc.ABCMeta, BlockingCoverage)):
"""Specification of test coverage for non-blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testParallelInvocations(self):
raise NotImplementedError()
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
index 179f3a2f67..b707dcdf6c 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import unittest
+import six
+
from grpc.framework.face import interfaces
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import callback as testing_callback
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class EventInvocationSynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
index 485524a356..4d27cbe186 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,8 @@ import contextlib
import threading
import unittest
+import six
+
from grpc.framework.face import exceptions
from grpc.framework.foundation import future
from grpc.framework.foundation import logging_pool
@@ -74,12 +76,12 @@ class _PauseableIterator(object):
class FutureInvocationAsynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
index 5932dabf1e..87be836e2d 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,14 @@
import abc
+import six
+
# cardinality is referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""An RPC method to be used in tests of RPC implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/service.py b/src/python/grpcio/tests/unit/framework/face/testing/service.py
index ac0b89b6ee..dc0f204c04 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/service.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/service.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,16 +31,16 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces
-class UnaryUnaryTestMethodImplementation(interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-unary RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message.
@@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class UnaryUnaryTestMessages(object):
+class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError()
-class UnaryStreamTestMethodImplementation(interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-stream RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages.
@@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class UnaryStreamTestMessages(object):
+class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError()
-class StreamUnaryTestMethodImplementation(interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-unary RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message.
@@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class StreamUnaryTestMessages(object):
+class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError()
-class StreamStreamTestMethodImplementation(interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-stream RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages.
@@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class StreamStreamTestMessages(object):
+class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError()
-class TestService(object):
+class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented RPC methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def name(self):
"""Identifies the RPC service name used during the test.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
index 23d4d919c2..5be9330a77 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,18 +31,19 @@
import abc
+import six
+
# face_interfaces and interfaces are referenced in specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import
-class FaceTestCase(object):
+class FaceTestCase(six.with_metaclass(abc.ABCMeta)):
"""Describes a test of the Face Layer of RPC Framework.
Concrete subclasses must also inherit from unittest.TestCase and from at least
one class that defines test methods.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_up_implementation(
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
index 38102b198a..fe69e63995 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,8 @@ import random # pylint: disable=unused-import
import threading
import time
+import six
+
from grpc.framework.interfaces.base import base
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.base import _sequence
@@ -247,8 +249,7 @@ class Instruction(
CONCLUDE = 'CONCLUDE'
-class Controller(object):
- __metaclass__ = abc.ABCMeta
+class Controller(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def failed(self, message):
@@ -308,8 +309,7 @@ class Controller(object):
raise NotImplementedError()
-class ControllerCreator(object):
- __metaclass__ = abc.ABCMeta
+class ControllerCreator(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
index 84afd24d47..0594cfeb31 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,13 @@
import abc
+import six
+
from grpc.framework.interfaces.base import base # pylint: disable=unused-import
-class Serialization(object):
+class Serialization(six.with_metaclass(abc.ABCMeta)):
"""Specifies serialization and deserialization of test payloads."""
- __metaclass__ = abc.ABCMeta
def serialize_request(self, request):
"""Serializes a request value used in a test.
@@ -85,9 +86,8 @@ class Serialization(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Base layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(self, serializations, servicer):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
index c8a3a1bc74..a47fcd3681 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
@@ -34,6 +34,8 @@ import itertools
import unittest
from concurrent import futures
+import six
+
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
@@ -46,14 +48,13 @@ from tests.unit.framework.interfaces.face import _stock_service
from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
-class TestCase(test_coverage.Coverage, unittest.TestCase):
+class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor.
"""
- __metaclass__ = abc.ABCMeta
NAME = 'BlockingInvocationInlineServiceTest'
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
index 1d36a931e8..fb4bee6f86 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
@@ -36,6 +36,8 @@ import threading
import unittest
from concurrent import futures
+import six
+
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
@@ -104,14 +106,13 @@ class _Callback(object):
self._condition.wait()
-class TestCase(test_coverage.Coverage, unittest.TestCase):
+class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor.
"""
- __metaclass__ = abc.ABCMeta
NAME = 'FutureInvocationAsynchronousEventServiceTest'
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
index 448e845a08..ff38dc2ece 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.common import cardinality
_CARDINALITY_TO_GENERIC_BLOCKING_BEHAVIOR = {
@@ -62,9 +64,8 @@ _CARDINALITY_TO_MULTI_CALLABLE_ATTRIBUTE = {
}
-class Invoker(object):
+class Invoker(six.with_metaclass(abc.ABCMeta)):
"""A type used to invoke test RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking(self, group, name):
@@ -82,9 +83,8 @@ class Invoker(object):
raise NotImplementedError()
-class InvokerConstructor(object):
+class InvokerConstructor(six.with_metaclass(abc.ABCMeta)):
"""A type used to create Invokers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
index 28941e2ad0..bec8d5113c 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,16 +31,16 @@
import abc
+import six
+
# face is referenced from specification in this module.
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
from tests.unit.framework.interfaces.face import test_interfaces
-class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message.
@@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryUnaryTestMessages(object):
+class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError()
-class UnaryStreamTestMethodImplementation(test_interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages.
@@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryStreamTestMessages(object):
+class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError()
-class StreamUnaryTestMethodImplementation(test_interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message.
@@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamUnaryTestMessages(object):
+class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError()
-class StreamStreamTestMethodImplementation(test_interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages.
@@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamStreamTestMessages(object):
+class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError()
-class TestService(object):
+class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def unary_unary_scenarios(self):
"""Affords unary-request-unary-response test methods and their messages.
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
index b2b5c10fa6..a5e28b7942 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,14 @@
import abc
+import six
+
from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""Specifies a method to be used in tests."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group(self):
@@ -126,9 +127,8 @@ class Method(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Face layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
index dace6c23f3..2283e79f0a 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.interfaces.links import links
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.links import test_utilities
@@ -58,13 +60,12 @@ _TRANSMISSION_GROUP = 'test.Group'
_TRANSMISSION_METHOD = 'TestMethod'
-class TransmissionTest(object):
+class TransmissionTest(six.with_metaclass(abc.ABCMeta)):
"""Tests ticket transmission between two connected links.
This class must be mixed into a unittest.TestCase that implements the abstract
methods it provides.
"""
- __metaclass__ = abc.ABCMeta
# This is a unittest.TestCase mix-in.
# pylint: disable=invalid-name