You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by tv...@apache.org on 2021/04/08 03:25:34 UTC

[beam] branch master updated: [BEAM-7372] remove usage of future package and unnecessary builtins import from internal and metrics (#14445)

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

tvalentyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 572fef9  [BEAM-7372] remove usage of future package and unnecessary builtins import from internal and metrics (#14445)
572fef9 is described below

commit 572fef9d06aeb06cd87d46e9f5078d83b29113eb
Author: yoshiki.obata <12...@users.noreply.github.com>
AuthorDate: Thu Apr 8 12:24:34 2021 +0900

    [BEAM-7372] remove usage of future package and unnecessary builtins import from internal and metrics (#14445)
---
 sdks/python/apache_beam/internal/__init__.py             |  2 --
 sdks/python/apache_beam/internal/gcp/__init__.py         |  2 --
 sdks/python/apache_beam/internal/gcp/auth.py             |  2 --
 sdks/python/apache_beam/internal/gcp/json_value.py       | 11 +++--------
 sdks/python/apache_beam/internal/gcp/json_value_test.py  |  2 --
 sdks/python/apache_beam/internal/http_client.py          |  2 --
 sdks/python/apache_beam/internal/http_client_test.py     |  2 --
 sdks/python/apache_beam/internal/metrics/__init__.py     |  2 --
 sdks/python/apache_beam/internal/metrics/cells.py        |  4 ----
 sdks/python/apache_beam/internal/metrics/cells_test.py   |  3 ---
 sdks/python/apache_beam/internal/metrics/metric.py       |  3 ---
 sdks/python/apache_beam/internal/metrics/metric_test.py  |  2 --
 sdks/python/apache_beam/internal/module_test.py          |  3 ---
 sdks/python/apache_beam/internal/pickler.py              |  7 ++-----
 sdks/python/apache_beam/internal/pickler_test.py         |  2 --
 sdks/python/apache_beam/internal/util.py                 |  3 ---
 sdks/python/apache_beam/internal/util_test.py            |  2 --
 sdks/python/apache_beam/metrics/__init__.py              |  2 --
 sdks/python/apache_beam/metrics/cells.py                 |  4 ----
 sdks/python/apache_beam/metrics/cells_test.py            |  3 ---
 sdks/python/apache_beam/metrics/execution.py             |  3 ---
 sdks/python/apache_beam/metrics/execution_test.py        |  3 ---
 sdks/python/apache_beam/metrics/metric.py                |  3 ---
 sdks/python/apache_beam/metrics/metric_test.py           |  3 ---
 sdks/python/apache_beam/metrics/metricbase.py            |  3 ---
 sdks/python/apache_beam/metrics/monitoring_infos.py      |  2 --
 sdks/python/apache_beam/metrics/monitoring_infos_test.py |  2 --
 27 files changed, 5 insertions(+), 77 deletions(-)

diff --git a/sdks/python/apache_beam/internal/__init__.py b/sdks/python/apache_beam/internal/__init__.py
index 84381ed..0bce5d6 100644
--- a/sdks/python/apache_beam/internal/__init__.py
+++ b/sdks/python/apache_beam/internal/__init__.py
@@ -16,5 +16,3 @@
 #
 
 """For internal use only; no backwards-compatibility guarantees."""
-
-from __future__ import absolute_import
diff --git a/sdks/python/apache_beam/internal/gcp/__init__.py b/sdks/python/apache_beam/internal/gcp/__init__.py
index 84381ed..0bce5d6 100644
--- a/sdks/python/apache_beam/internal/gcp/__init__.py
+++ b/sdks/python/apache_beam/internal/gcp/__init__.py
@@ -16,5 +16,3 @@
 #
 
 """For internal use only; no backwards-compatibility guarantees."""
-
-from __future__ import absolute_import
diff --git a/sdks/python/apache_beam/internal/gcp/auth.py b/sdks/python/apache_beam/internal/gcp/auth.py
index 636cab6..b3dbe32 100644
--- a/sdks/python/apache_beam/internal/gcp/auth.py
+++ b/sdks/python/apache_beam/internal/gcp/auth.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import logging
 import socket
 import threading
diff --git a/sdks/python/apache_beam/internal/gcp/json_value.py b/sdks/python/apache_beam/internal/gcp/json_value.py
index 60009ac..c7d561e 100644
--- a/sdks/python/apache_beam/internal/gcp/json_value.py
+++ b/sdks/python/apache_beam/internal/gcp/json_value.py
@@ -19,11 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
-from past.builtins import long
-from past.builtins import unicode
-
 from apache_beam.options.value_provider import ValueProvider
 
 # Protect against environments where apitools library is not available.
@@ -54,7 +49,7 @@ def get_typed_value_descriptor(obj):
     TypeError: if the Python object has a type that is not
       supported.
   """
-  if isinstance(obj, (bytes, unicode)):
+  if isinstance(obj, (bytes, str)):
     type_name = 'Text'
   elif isinstance(obj, bool):
     type_name = 'Boolean'
@@ -106,13 +101,13 @@ def to_json_value(obj, with_type=False):
     return extra_types.JsonValue(object_value=json_object)
   elif with_type:
     return to_json_value(get_typed_value_descriptor(obj), with_type=False)
-  elif isinstance(obj, (str, unicode)):
+  elif isinstance(obj, str):
     return extra_types.JsonValue(string_value=obj)
   elif isinstance(obj, bytes):
     return extra_types.JsonValue(string_value=obj.decode('utf8'))
   elif isinstance(obj, bool):
     return extra_types.JsonValue(boolean_value=obj)
-  elif isinstance(obj, (int, long)):
+  elif isinstance(obj, int):
     if _MININT64 <= obj <= _MAXINT64:
       return extra_types.JsonValue(integer_value=obj)
     else:
diff --git a/sdks/python/apache_beam/internal/gcp/json_value_test.py b/sdks/python/apache_beam/internal/gcp/json_value_test.py
index 4b21b4f..21337de 100644
--- a/sdks/python/apache_beam/internal/gcp/json_value_test.py
+++ b/sdks/python/apache_beam/internal/gcp/json_value_test.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
 
 from apache_beam.internal.gcp.json_value import from_json_value
diff --git a/sdks/python/apache_beam/internal/http_client.py b/sdks/python/apache_beam/internal/http_client.py
index 57d2feb..50c2a5a 100644
--- a/sdks/python/apache_beam/internal/http_client.py
+++ b/sdks/python/apache_beam/internal/http_client.py
@@ -21,8 +21,6 @@ For internal use only. No backwards compatibility guarantees.
 """
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import logging
 import os
 import re
diff --git a/sdks/python/apache_beam/internal/http_client_test.py b/sdks/python/apache_beam/internal/http_client_test.py
index 6a403a9..c879078 100644
--- a/sdks/python/apache_beam/internal/http_client_test.py
+++ b/sdks/python/apache_beam/internal/http_client_test.py
@@ -18,8 +18,6 @@
 """Unit tests for the http_client module."""
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import os
 import unittest
 
diff --git a/sdks/python/apache_beam/internal/metrics/__init__.py b/sdks/python/apache_beam/internal/metrics/__init__.py
index 84381ed..0bce5d6 100644
--- a/sdks/python/apache_beam/internal/metrics/__init__.py
+++ b/sdks/python/apache_beam/internal/metrics/__init__.py
@@ -16,5 +16,3 @@
 #
 
 """For internal use only; no backwards-compatibility guarantees."""
-
-from __future__ import absolute_import
diff --git a/sdks/python/apache_beam/internal/metrics/cells.py b/sdks/python/apache_beam/internal/metrics/cells.py
index 2b12760..3fcaecf 100644
--- a/sdks/python/apache_beam/internal/metrics/cells.py
+++ b/sdks/python/apache_beam/internal/metrics/cells.py
@@ -25,10 +25,6 @@ For internal use only. No backwards compatibility guarantees.
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-
-from builtins import object
 from typing import TYPE_CHECKING
 from typing import Optional
 
diff --git a/sdks/python/apache_beam/internal/metrics/cells_test.py b/sdks/python/apache_beam/internal/metrics/cells_test.py
index 89fe23d..066dec4 100644
--- a/sdks/python/apache_beam/internal/metrics/cells_test.py
+++ b/sdks/python/apache_beam/internal/metrics/cells_test.py
@@ -17,11 +17,8 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import threading
 import unittest
-from builtins import range
 
 from apache_beam.internal.metrics.cells import HistogramCell
 from apache_beam.internal.metrics.cells import HistogramCellFactory
diff --git a/sdks/python/apache_beam/internal/metrics/metric.py b/sdks/python/apache_beam/internal/metrics/metric.py
index 069919e..0510674 100644
--- a/sdks/python/apache_beam/internal/metrics/metric.py
+++ b/sdks/python/apache_beam/internal/metrics/metric.py
@@ -25,13 +25,10 @@ For internal use only. No backwards compatibility guarantees.
 # pytype: skip-file
 # mypy: disallow-untyped-defs
 
-from __future__ import absolute_import
-
 import datetime
 import logging
 import threading
 import time
-from builtins import object
 from typing import TYPE_CHECKING
 from typing import Dict
 from typing import Optional
diff --git a/sdks/python/apache_beam/internal/metrics/metric_test.py b/sdks/python/apache_beam/internal/metrics/metric_test.py
index bef7713..22b64ee 100644
--- a/sdks/python/apache_beam/internal/metrics/metric_test.py
+++ b/sdks/python/apache_beam/internal/metrics/metric_test.py
@@ -17,8 +17,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
 
 from mock import patch
diff --git a/sdks/python/apache_beam/internal/module_test.py b/sdks/python/apache_beam/internal/module_test.py
index c30f249..eaa1629 100644
--- a/sdks/python/apache_beam/internal/module_test.py
+++ b/sdks/python/apache_beam/internal/module_test.py
@@ -19,11 +19,8 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import re
 import sys
-from builtins import object
 from typing import Type
 
 
diff --git a/sdks/python/apache_beam/internal/pickler.py b/sdks/python/apache_beam/internal/pickler.py
index 4b9ec2a..13c98dc 100644
--- a/sdks/python/apache_beam/internal/pickler.py
+++ b/sdks/python/apache_beam/internal/pickler.py
@@ -30,8 +30,6 @@ the coders.*PickleCoder classes should be used instead.
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import base64
 import bz2
 import logging
@@ -75,9 +73,8 @@ def _is_nested_class(cls):
   """Returns true if argument is a class object that appears to be nested."""
   return (
       isinstance(cls, type) and cls.__module__ is not None and
-      cls.__module__ != 'builtins'  # Python 3
-      and cls.__module__ != '__builtin__'  # Python 2
-      and cls.__name__ not in sys.modules[cls.__module__].__dict__)
+      cls.__module__ != 'builtins' and
+      cls.__name__ not in sys.modules[cls.__module__].__dict__)
 
 
 def _find_containing_class(nested_class):
diff --git a/sdks/python/apache_beam/internal/pickler_test.py b/sdks/python/apache_beam/internal/pickler_test.py
index 929e701..15e62a7 100644
--- a/sdks/python/apache_beam/internal/pickler_test.py
+++ b/sdks/python/apache_beam/internal/pickler_test.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import sys
 import types
 import unittest
diff --git a/sdks/python/apache_beam/internal/util.py b/sdks/python/apache_beam/internal/util.py
index e95c30e..f0a3ad8 100644
--- a/sdks/python/apache_beam/internal/util.py
+++ b/sdks/python/apache_beam/internal/util.py
@@ -22,12 +22,9 @@ For internal use only. No backwards compatibility guarantees.
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import logging
 import threading
 import weakref
-from builtins import object
 from multiprocessing.pool import ThreadPool
 from typing import Any
 from typing import Dict
diff --git a/sdks/python/apache_beam/internal/util_test.py b/sdks/python/apache_beam/internal/util_test.py
index bb0ae37..ded1190 100644
--- a/sdks/python/apache_beam/internal/util_test.py
+++ b/sdks/python/apache_beam/internal/util_test.py
@@ -18,8 +18,6 @@
 """Unit tests for the util module."""
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
 
 from apache_beam.internal.util import ArgumentPlaceholder
diff --git a/sdks/python/apache_beam/metrics/__init__.py b/sdks/python/apache_beam/metrics/__init__.py
index e74168f..8ce7bbb 100644
--- a/sdks/python/apache_beam/metrics/__init__.py
+++ b/sdks/python/apache_beam/metrics/__init__.py
@@ -14,7 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-from __future__ import absolute_import
-
 from apache_beam.metrics.metric import Metrics
 from apache_beam.metrics.metric import MetricsFilter
diff --git a/sdks/python/apache_beam/metrics/cells.py b/sdks/python/apache_beam/metrics/cells.py
index 404c305..0c6b8f3 100644
--- a/sdks/python/apache_beam/metrics/cells.py
+++ b/sdks/python/apache_beam/metrics/cells.py
@@ -25,12 +25,8 @@ context.
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-
 import threading
 import time
-from builtins import object
 from datetime import datetime
 from typing import Any
 from typing import Optional
diff --git a/sdks/python/apache_beam/metrics/cells_test.py b/sdks/python/apache_beam/metrics/cells_test.py
index a120d15..3d4d81c 100644
--- a/sdks/python/apache_beam/metrics/cells_test.py
+++ b/sdks/python/apache_beam/metrics/cells_test.py
@@ -17,11 +17,8 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import threading
 import unittest
-from builtins import range
 
 from apache_beam.metrics.cells import CounterCell
 from apache_beam.metrics.cells import DistributionCell
diff --git a/sdks/python/apache_beam/metrics/execution.py b/sdks/python/apache_beam/metrics/execution.py
index a6b11b2..9400860 100644
--- a/sdks/python/apache_beam/metrics/execution.py
+++ b/sdks/python/apache_beam/metrics/execution.py
@@ -34,10 +34,7 @@ Available classes:
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import threading
-from builtins import object
 from typing import TYPE_CHECKING
 from typing import Any
 from typing import Dict
diff --git a/sdks/python/apache_beam/metrics/execution_test.py b/sdks/python/apache_beam/metrics/execution_test.py
index d1086da..a888376 100644
--- a/sdks/python/apache_beam/metrics/execution_test.py
+++ b/sdks/python/apache_beam/metrics/execution_test.py
@@ -17,10 +17,7 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
-from builtins import range
 
 from apache_beam.metrics.execution import MetricKey
 from apache_beam.metrics.execution import MetricsContainer
diff --git a/sdks/python/apache_beam/metrics/metric.py b/sdks/python/apache_beam/metrics/metric.py
index 2ca0984..f4896e9 100644
--- a/sdks/python/apache_beam/metrics/metric.py
+++ b/sdks/python/apache_beam/metrics/metric.py
@@ -27,10 +27,7 @@ and displayed as part of their pipeline execution.
 # pytype: skip-file
 # mypy: disallow-untyped-defs
 
-from __future__ import absolute_import
-
 import logging
-from builtins import object
 from typing import TYPE_CHECKING
 from typing import Dict
 from typing import FrozenSet
diff --git a/sdks/python/apache_beam/metrics/metric_test.py b/sdks/python/apache_beam/metrics/metric_test.py
index a0f75ed..3771d60 100644
--- a/sdks/python/apache_beam/metrics/metric_test.py
+++ b/sdks/python/apache_beam/metrics/metric_test.py
@@ -17,10 +17,7 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
-from builtins import object
 
 import hamcrest as hc
 from nose.plugins.attrib import attr
diff --git a/sdks/python/apache_beam/metrics/metricbase.py b/sdks/python/apache_beam/metrics/metricbase.py
index fbd6f79..12e7881 100644
--- a/sdks/python/apache_beam/metrics/metricbase.py
+++ b/sdks/python/apache_beam/metrics/metricbase.py
@@ -34,9 +34,6 @@ Available classes:
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
-from builtins import object
 from typing import Dict
 from typing import Optional
 
diff --git a/sdks/python/apache_beam/metrics/monitoring_infos.py b/sdks/python/apache_beam/metrics/monitoring_infos.py
index 33bb1ca..2875810 100644
--- a/sdks/python/apache_beam/metrics/monitoring_infos.py
+++ b/sdks/python/apache_beam/metrics/monitoring_infos.py
@@ -20,8 +20,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import collections
 import time
 from functools import reduce
diff --git a/sdks/python/apache_beam/metrics/monitoring_infos_test.py b/sdks/python/apache_beam/metrics/monitoring_infos_test.py
index 2855e23..d19e8bc 100644
--- a/sdks/python/apache_beam/metrics/monitoring_infos_test.py
+++ b/sdks/python/apache_beam/metrics/monitoring_infos_test.py
@@ -16,8 +16,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
 
 from apache_beam.metrics import monitoring_infos