[
https://issues.apache.org/jira/browse/BEAM-3999?focusedWorklogId=104836&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-104836
]
ASF GitHub Bot logged work on BEAM-3999:
----------------------------------------
Author: ASF GitHub Bot
Created on: 22/May/18 22:12
Start Date: 22/May/18 22:12
Worklog Time Spent: 10m
Work Description: aaltay closed pull request #5334: [BEAM-3999] Futurize
internal subpackage
URL: https://github.com/apache/beam/pull/5334
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/sdks/python/apache_beam/internal/__init__.py
b/sdks/python/apache_beam/internal/__init__.py
index 0bce5d68f72..84381ed71d4 100644
--- a/sdks/python/apache_beam/internal/__init__.py
+++ b/sdks/python/apache_beam/internal/__init__.py
@@ -16,3 +16,5 @@
#
"""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 0bce5d68f72..84381ed71d4 100644
--- a/sdks/python/apache_beam/internal/gcp/__init__.py
+++ b/sdks/python/apache_beam/internal/gcp/__init__.py
@@ -16,3 +16,5 @@
#
"""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 97a0ef83e85..cff88879d1a 100644
--- a/sdks/python/apache_beam/internal/gcp/auth.py
+++ b/sdks/python/apache_beam/internal/gcp/auth.py
@@ -17,17 +17,19 @@
"""Dataflow credentials and authentication."""
+from __future__ import absolute_import
+
import datetime
import json
import logging
import os
+from future.moves.urllib.request import Request
+from future.moves.urllib.request import urlopen
from oauth2client.client import GoogleCredentials
from oauth2client.client import OAuth2Credentials
from apache_beam.utils import retry
-from six.moves.urllib.request import Request
-from six.moves.urllib.request import urlopen
# When we are running in GCE, we can authenticate with VM credentials.
is_running_in_gce = False
diff --git a/sdks/python/apache_beam/internal/gcp/json_value.py
b/sdks/python/apache_beam/internal/gcp/json_value.py
index c4f3d7ba4da..a4c6fb9d135 100644
--- a/sdks/python/apache_beam/internal/gcp/json_value.py
+++ b/sdks/python/apache_beam/internal/gcp/json_value.py
@@ -17,6 +17,10 @@
"""JSON conversion utility functions."""
+from __future__ import absolute_import
+
+from apache_beam.options.value_provider import ValueProvider
+
# Protect against environments where apitools library is not available.
# pylint: disable=wrong-import-order, wrong-import-position
try:
@@ -25,9 +29,12 @@
extra_types = None
# pylint: enable=wrong-import-order, wrong-import-position
-import six
-
-from apache_beam.options.value_provider import ValueProvider
+try: # Python 2
+ unicode # pylint: disable=unicode-builtin
+ long # pylint: disable=long-builtin
+except NameError: # Python 3
+ unicode = str
+ long = int
_MAXINT64 = (1 << 63) - 1
_MININT64 = - (1 << 63)
@@ -49,7 +56,7 @@ def get_typed_value_descriptor(obj):
~exceptions.TypeError: if the Python object has a type that is not
supported.
"""
- if isinstance(obj, six.string_types):
+ if isinstance(obj, (str, unicode)):
type_name = 'Text'
elif isinstance(obj, bool):
type_name = 'Boolean'
@@ -101,11 +108,11 @@ 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, six.string_types):
+ elif isinstance(obj, (str, unicode)):
return extra_types.JsonValue(string_value=obj)
elif isinstance(obj, bool):
return extra_types.JsonValue(boolean_value=obj)
- elif isinstance(obj, six.integer_types):
+ elif isinstance(obj, (int, long)):
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 c22d067beea..e7cf7f15e36 100644
--- a/sdks/python/apache_beam/internal/gcp/json_value_test.py
+++ b/sdks/python/apache_beam/internal/gcp/json_value_test.py
@@ -17,6 +17,8 @@
"""Unit tests for the json_value module."""
+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/module_test.py
b/sdks/python/apache_beam/internal/module_test.py
index be34ac27e25..baed9652b69 100644
--- a/sdks/python/apache_beam/internal/module_test.py
+++ b/sdks/python/apache_beam/internal/module_test.py
@@ -17,7 +17,10 @@
"""Module used to define functions and classes used by the coder unit tests."""
+from __future__ import absolute_import
+
import re
+from builtins import object
class TopClass(object):
diff --git a/sdks/python/apache_beam/internal/pickler.py
b/sdks/python/apache_beam/internal/pickler.py
index 3e4fe05974b..3a04d8c36bf 100644
--- a/sdks/python/apache_beam/internal/pickler.py
+++ b/sdks/python/apache_beam/internal/pickler.py
@@ -28,6 +28,8 @@
the coders.*PickleCoder classes should be used instead.
"""
+from __future__ import absolute_import
+
import base64
import logging
import sys
diff --git a/sdks/python/apache_beam/internal/pickler_test.py
b/sdks/python/apache_beam/internal/pickler_test.py
index e75dac38462..79208aa1070 100644
--- a/sdks/python/apache_beam/internal/pickler_test.py
+++ b/sdks/python/apache_beam/internal/pickler_test.py
@@ -17,6 +17,8 @@
"""Unit tests for the pickler module."""
+from __future__ import absolute_import
+
import unittest
from apache_beam.internal import module_test
diff --git a/sdks/python/apache_beam/internal/util.py
b/sdks/python/apache_beam/internal/util.py
index e74dd4333ac..afa4b0563b8 100644
--- a/sdks/python/apache_beam/internal/util.py
+++ b/sdks/python/apache_beam/internal/util.py
@@ -20,9 +20,12 @@
For internal use only. No backwards compatibility guarantees.
"""
+from __future__ import absolute_import
+
import logging
import threading
import weakref
+from builtins import object
from multiprocessing.pool import ThreadPool
@@ -51,6 +54,9 @@ def __eq__(self, other):
"""
return isinstance(other, ArgumentPlaceholder)
+ def __hash__(self):
+ return hash(type(self))
+
def remove_objects_from_args(args, kwargs, pvalue_classes):
"""For internal use only; no backwards-compatibility guarantees.
diff --git a/sdks/python/apache_beam/internal/util_test.py
b/sdks/python/apache_beam/internal/util_test.py
index 9a2e3977a70..aeba8dcdf44 100644
--- a/sdks/python/apache_beam/internal/util_test.py
+++ b/sdks/python/apache_beam/internal/util_test.py
@@ -16,6 +16,7 @@
#
"""Unit tests for the util module."""
+from __future__ import absolute_import
import unittest
diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini
index 61dc12c3017..481c5f984a0 100644
--- a/sdks/python/tox.ini
+++ b/sdks/python/tox.ini
@@ -99,6 +99,7 @@ deps =
flake8==3.5.0
modules =
apache_beam/coders
+ apache_beam/internal
apache_beam/metrics
commands =
python --version
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 104836)
Time Spent: 3h (was: 2h 50m)
> Futurize and fix python 2 compatibility for internal subpackage
> ---------------------------------------------------------------
>
> Key: BEAM-3999
> URL: https://issues.apache.org/jira/browse/BEAM-3999
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-py-core
> Reporter: Robbe
> Assignee: Robbe
> Priority: Major
> Time Spent: 3h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)