You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by di...@apache.org on 2020/10/31 01:35:24 UTC

[flink] branch release-1.11 updated: [FLINK-19892][python] Replace __metaclass__ field with metaclass keyword

This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.11 by this push:
     new 0656151  [FLINK-19892][python] Replace __metaclass__ field with metaclass keyword
0656151 is described below

commit 06561515d62deec1b552064b97d5c27495e14f16
Author: SteNicholas <pr...@163.com>
AuthorDate: Fri Oct 30 16:49:19 2020 +0800

    [FLINK-19892][python] Replace __metaclass__ field with metaclass keyword
    
    This closes #13856.
---
 flink-python/pyflink/common/restart_strategy.py  |  4 +---
 flink-python/pyflink/datastream/state_backend.py |  4 +---
 flink-python/pyflink/ml/api/base.py              | 12 +++---------
 flink-python/pyflink/serializers.py              |  4 +---
 flink-python/pyflink/table/descriptors.py        | 16 ++++------------
 flink-python/pyflink/table/table_environment.py  |  4 +---
 6 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/flink-python/pyflink/common/restart_strategy.py b/flink-python/pyflink/common/restart_strategy.py
index 6fc977d..8f1b98d 100644
--- a/flink-python/pyflink/common/restart_strategy.py
+++ b/flink-python/pyflink/common/restart_strategy.py
@@ -26,13 +26,11 @@ from pyflink.util.utils import to_j_flink_time, from_j_flink_time
 __all__ = ['RestartStrategies', 'RestartStrategyConfiguration']
 
 
-class RestartStrategyConfiguration(object):
+class RestartStrategyConfiguration(object, metaclass=ABCMeta):
     """
     Abstract configuration for restart strategies.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, j_restart_strategy_configuration):
         self._j_restart_strategy_configuration = j_restart_strategy_configuration
 
diff --git a/flink-python/pyflink/datastream/state_backend.py b/flink-python/pyflink/datastream/state_backend.py
index a6bd873..d564614 100644
--- a/flink-python/pyflink/datastream/state_backend.py
+++ b/flink-python/pyflink/datastream/state_backend.py
@@ -55,7 +55,7 @@ def _from_j_state_backend(j_state_backend):
         return CustomStateBackend(j_state_backend)  # users' customized state backend
 
 
-class StateBackend(object):
+class StateBackend(object, metaclass=ABCMeta):
     """
     A **State Backend** defines how the state of a streaming application is stored and
     checkpointed. Different State Backends store their state in different fashions, and use
@@ -110,8 +110,6 @@ class StateBackend(object):
     streams and keyed-/operator state backends concurrently.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
diff --git a/flink-python/pyflink/ml/api/base.py b/flink-python/pyflink/ml/api/base.py
index 1ae66df..2db1249 100644
--- a/flink-python/pyflink/ml/api/base.py
+++ b/flink-python/pyflink/ml/api/base.py
@@ -74,15 +74,13 @@ class PipelineStage(WithParams):
         self.get_params().load_json(json)
 
 
-class Transformer(PipelineStage):
+class Transformer(PipelineStage, metaclass=ABCMeta):
     """
     A transformer is a PipelineStage that transforms an input Table to a result Table.
 
     .. versionadded:: 1.11.0
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractmethod
     def transform(self, table_env: TableEnvironment, table: Table) -> Table:
         """
@@ -123,7 +121,7 @@ class JavaTransformer(Transformer):
         return Table(self._j_obj.transform(table_env._j_tenv, table._j_table), table_env)
 
 
-class Model(Transformer):
+class Model(Transformer, metaclass=ABCMeta):
     """
     Abstract class for models that are fitted by estimators.
 
@@ -134,8 +132,6 @@ class Model(Transformer):
     .. versionadded:: 1.11.0
     """
 
-    __metaclass__ = ABCMeta
-
 
 class JavaModel(JavaTransformer, Model):
     """
@@ -146,7 +142,7 @@ class JavaModel(JavaTransformer, Model):
     """
 
 
-class Estimator(PipelineStage):
+class Estimator(PipelineStage, metaclass=ABCMeta):
     """
     Estimators are PipelineStages responsible for training and generating machine learning models.
 
@@ -156,8 +152,6 @@ class Estimator(PipelineStage):
     .. versionadded:: 1.11.0
     """
 
-    __metaclass__ = ABCMeta
-
     def fit(self, table_env: TableEnvironment, table: Table) -> Model:
         """
         Train and produce a Model which fits the records in the given Table.
diff --git a/flink-python/pyflink/serializers.py b/flink-python/pyflink/serializers.py
index c894c21..e015201 100644
--- a/flink-python/pyflink/serializers.py
+++ b/flink-python/pyflink/serializers.py
@@ -27,9 +27,7 @@ class SpecialLengths(object):
     NULL = -2
 
 
-class Serializer(object):
-
-    __metaclass__ = ABCMeta
+class Serializer(object, metaclass=ABCMeta):
 
     # Note: our notion of "equality" is that output generated by
     # equal serializers can be deserialized using the same serializer.
diff --git a/flink-python/pyflink/table/descriptors.py b/flink-python/pyflink/table/descriptors.py
index 561d83c..9bdc640 100644
--- a/flink-python/pyflink/table/descriptors.py
+++ b/flink-python/pyflink/table/descriptors.py
@@ -43,7 +43,7 @@ __all__ = [
 ]
 
 
-class Descriptor(object):
+class Descriptor(object, metaclass=ABCMeta):
     """
     Base class of the descriptors that adds a set of string-based, normalized properties for
     describing DDL information.
@@ -57,8 +57,6 @@ class Descriptor(object):
     properties.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, j_descriptor):
         self._j_descriptor = j_descriptor
 
@@ -298,13 +296,11 @@ class Schema(Descriptor):
         return self
 
 
-class FormatDescriptor(Descriptor):
+class FormatDescriptor(Descriptor, metaclass=ABCMeta):
     """
     Describes the format of data.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, j_format_descriptor):
         self._j_format_descriptor = j_format_descriptor
         super(FormatDescriptor, self).__init__(self._j_format_descriptor)
@@ -821,13 +817,11 @@ class CustomFormatDescriptor(FormatDescriptor):
         return self
 
 
-class ConnectorDescriptor(Descriptor):
+class ConnectorDescriptor(Descriptor, metaclass=ABCMeta):
     """
     Describes a connector to an other system.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, j_connector_descriptor):
         self._j_connector_descriptor = j_connector_descriptor
         super(ConnectorDescriptor, self).__init__(self._j_connector_descriptor)
@@ -1734,13 +1728,11 @@ class CustomConnectorDescriptor(ConnectorDescriptor):
         return self
 
 
-class ConnectTableDescriptor(Descriptor):
+class ConnectTableDescriptor(Descriptor, metaclass=ABCMeta):
     """
     Common class for table's created with :class:`pyflink.table.TableEnvironment.connect`.
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, j_connect_table_descriptor):
         self._j_connect_table_descriptor = j_connect_table_descriptor
         super(ConnectTableDescriptor, self).__init__(self._j_connect_table_descriptor)
diff --git a/flink-python/pyflink/table/table_environment.py b/flink-python/pyflink/table/table_environment.py
index e7f5698..f16f2b1 100644
--- a/flink-python/pyflink/table/table_environment.py
+++ b/flink-python/pyflink/table/table_environment.py
@@ -49,7 +49,7 @@ __all__ = [
 ]
 
 
-class TableEnvironment(object):
+class TableEnvironment(object, metaclass=ABCMeta):
     """
     A table environment is the base class, entry point, and central context for creating Table
     and SQL API programs.
@@ -81,8 +81,6 @@ class TableEnvironment(object):
 
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, j_tenv, serializer=PickleSerializer()):
         self._j_tenv = j_tenv
         self._is_blink_planner = TableEnvironment._judge_blink_planner(j_tenv)