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 cb31b7b  [BEAM-7372] cleanup codes for py2 compatibility from 
apache_beam/examples/snippets/*.py and apache_beam/examples/*.py (#14444)
cb31b7b is described below

commit cb31b7b6494ffe69480bb590562129bee93d64d1
Author: yoshiki.obata <[email protected]>
AuthorDate: Thu Apr 8 12:27:26 2021 +0900

    [BEAM-7372] cleanup codes for py2 compatibility from 
apache_beam/examples/snippets/*.py and apache_beam/examples/*.py (#14444)
    
    * usage of future package
     * usage of past package
     * unnecessary builtin import
     * workarounds for py2
---
 sdks/python/apache_beam/examples/__init__.py       |   2 -
 sdks/python/apache_beam/examples/avro_bitcoin.py   |  11 +-
 .../apache_beam/examples/fastavro_it_test.py       |  11 +-
 .../apache_beam/examples/snippets/__init__.py      |   2 -
 .../apache_beam/examples/snippets/snippets.py      |   6 --
 .../apache_beam/examples/snippets/snippets_test.py |  80 +++++++++++++--
 .../examples/snippets/snippets_test_py3.py         | 114 ---------------------
 .../examples/snippets/transforms/__init__.py       |   2 -
 .../snippets/transforms/aggregation/__init__.py    |   2 -
 .../transforms/aggregation/cogroupbykey.py         |   3 -
 .../transforms/aggregation/cogroupbykey_test.py    |   3 -
 .../transforms/aggregation/combineglobally.py      |   4 -
 .../transforms/aggregation/combineglobally_test.py |   3 -
 .../transforms/aggregation/combineperkey.py        |   4 -
 .../transforms/aggregation/combineperkey_test.py   |   3 -
 .../transforms/aggregation/combinevalues.py        |   4 -
 .../transforms/aggregation/combinevalues_test.py   |   3 -
 .../snippets/transforms/aggregation/count.py       |   3 -
 .../snippets/transforms/aggregation/count_test.py  |   3 -
 .../snippets/transforms/aggregation/distinct.py    |   3 -
 .../transforms/aggregation/distinct_test.py        |   3 -
 .../transforms/aggregation/groupby_test.py         |   4 -
 .../snippets/transforms/aggregation/groupbykey.py  |   3 -
 .../transforms/aggregation/groupbykey_test.py      |   3 -
 .../transforms/aggregation/groupintobatches.py     |   3 -
 .../aggregation/groupintobatches_test.py           |   3 -
 .../snippets/transforms/aggregation/latest.py      |   3 -
 .../snippets/transforms/aggregation/latest_test.py |   3 -
 .../snippets/transforms/aggregation/max.py         |   3 -
 .../snippets/transforms/aggregation/max_test.py    |   3 -
 .../snippets/transforms/aggregation/mean.py        |   3 -
 .../snippets/transforms/aggregation/mean_test.py   |   3 -
 .../snippets/transforms/aggregation/min.py         |   3 -
 .../snippets/transforms/aggregation/min_test.py    |   3 -
 .../snippets/transforms/aggregation/sample.py      |   3 -
 .../snippets/transforms/aggregation/sample_test.py |   3 -
 .../snippets/transforms/aggregation/sum.py         |   3 -
 .../snippets/transforms/aggregation/sum_test.py    |   3 -
 .../snippets/transforms/aggregation/top.py         |   3 -
 .../snippets/transforms/aggregation/top_test.py    |   3 -
 .../snippets/transforms/elementwise/__init__.py    |   2 -
 .../snippets/transforms/elementwise/filter.py      |   3 -
 .../snippets/transforms/elementwise/filter_test.py |   3 -
 .../snippets/transforms/elementwise/flatmap.py     |   3 -
 .../transforms/elementwise/flatmap_test.py         |   3 -
 .../snippets/transforms/elementwise/keys.py        |   3 -
 .../snippets/transforms/elementwise/keys_test.py   |   3 -
 .../snippets/transforms/elementwise/kvswap.py      |   3 -
 .../snippets/transforms/elementwise/kvswap_test.py |   3 -
 .../snippets/transforms/elementwise/map.py         |   3 -
 .../snippets/transforms/elementwise/map_test.py    |   3 -
 .../snippets/transforms/elementwise/pardo.py       |   3 -
 .../snippets/transforms/elementwise/pardo_test.py  |   3 -
 .../snippets/transforms/elementwise/partition.py   |   3 -
 .../transforms/elementwise/partition_test.py       |   3 -
 .../snippets/transforms/elementwise/regex.py       |   3 -
 .../snippets/transforms/elementwise/regex_test.py  |   3 -
 .../snippets/transforms/elementwise/tostring.py    |   3 -
 .../transforms/elementwise/tostring_test.py        |   3 -
 .../snippets/transforms/elementwise/values.py      |   3 -
 .../snippets/transforms/elementwise/values_test.py |   3 -
 .../transforms/elementwise/withtimestamps.py       |   3 -
 .../transforms/elementwise/withtimestamps_test.py  |   3 -
 sdks/python/apache_beam/examples/snippets/util.py  |   2 -
 .../apache_beam/examples/snippets/util_test.py     |   2 -
 sdks/python/apache_beam/examples/sql_taxi.py       |   2 -
 .../apache_beam/examples/streaming_wordcount.py    |   7 +-
 .../examples/streaming_wordcount_debugging.py      |   7 +-
 .../streaming_wordcount_debugging_it_test.py       |   2 -
 .../examples/streaming_wordcount_debugging_test.py |   2 -
 .../examples/streaming_wordcount_it_test.py        |   3 -
 .../apache_beam/examples/windowed_wordcount.py     |   6 +-
 sdks/python/apache_beam/examples/wordcount.py      |   7 +-
 .../apache_beam/examples/wordcount_dataframe.py    |   2 -
 .../examples/wordcount_dataframe_test.py           |   2 -
 .../apache_beam/examples/wordcount_debugging.py    |   8 +-
 .../examples/wordcount_debugging_test.py           |   2 -
 .../apache_beam/examples/wordcount_it_test.py      |   2 -
 .../apache_beam/examples/wordcount_minimal.py      |   8 +-
 .../apache_beam/examples/wordcount_minimal_test.py |   2 -
 sdks/python/apache_beam/examples/wordcount_test.py |   2 -
 .../apache_beam/examples/wordcount_with_metrics.py |   7 +-
 .../python/apache_beam/examples/wordcount_xlang.py |   6 +-
 .../apache_beam/examples/wordcount_xlang_sql.py    |   8 +-
 84 files changed, 88 insertions(+), 396 deletions(-)

diff --git a/sdks/python/apache_beam/examples/__init__.py 
b/sdks/python/apache_beam/examples/__init__.py
index 6569e3f..cce3aca 100644
--- a/sdks/python/apache_beam/examples/__init__.py
+++ b/sdks/python/apache_beam/examples/__init__.py
@@ -14,5 +14,3 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-from __future__ import absolute_import
diff --git a/sdks/python/apache_beam/examples/avro_bitcoin.py 
b/sdks/python/apache_beam/examples/avro_bitcoin.py
index f877aaf..df7fad6 100644
--- a/sdks/python/apache_beam/examples/avro_bitcoin.py
+++ b/sdks/python/apache_beam/examples/avro_bitcoin.py
@@ -26,11 +26,11 @@ python -m apache_beam.examples.bitcoin \
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 
+from avro.schema import Parse
+
 import apache_beam as beam
 from apache_beam.io.avroio import ReadFromAvro
 from apache_beam.io.avroio import WriteToAvro
@@ -38,13 +38,6 @@ from apache_beam.metrics import Metrics
 from apache_beam.options.pipeline_options import PipelineOptions
 from apache_beam.options.pipeline_options import SetupOptions
 
-# pylint: disable=wrong-import-order, wrong-import-position
-try:
-  from avro.schema import Parse  # avro-python3 library for python3
-except ImportError:
-  from avro.schema import parse as Parse  # avro library for python2
-# pylint: enable=wrong-import-order, wrong-import-position
-
 
 class BitcoinTxnCountDoFn(beam.DoFn):
   """Count inputs and outputs per transaction"""
diff --git a/sdks/python/apache_beam/examples/fastavro_it_test.py 
b/sdks/python/apache_beam/examples/fastavro_it_test.py
index d4aca2c..9ac8051 100644
--- a/sdks/python/apache_beam/examples/fastavro_it_test.py
+++ b/sdks/python/apache_beam/examples/fastavro_it_test.py
@@ -45,14 +45,12 @@ Usage:
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-
 import json
 import logging
 import unittest
 import uuid
 
+from avro.schema import Parse
 from fastavro import parse_schema
 from nose.plugins.attrib import attr
 
@@ -67,13 +65,6 @@ from apache_beam.transforms.core import FlatMap
 from apache_beam.transforms.core import Map
 from apache_beam.transforms.util import CoGroupByKey
 
-# pylint: disable=wrong-import-order, wrong-import-position
-try:
-  from avro.schema import Parse  # avro-python3 library for python3
-except ImportError:
-  from avro.schema import parse as Parse  # avro library for python2
-# pylint: enable=wrong-import-order, wrong-import-position
-
 LABELS = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx']
 COLORS = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'PURPLE', None]
 
diff --git a/sdks/python/apache_beam/examples/snippets/__init__.py 
b/sdks/python/apache_beam/examples/snippets/__init__.py
index 6569e3f..cce3aca 100644
--- a/sdks/python/apache_beam/examples/snippets/__init__.py
+++ b/sdks/python/apache_beam/examples/snippets/__init__.py
@@ -14,5 +14,3 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-from __future__ import absolute_import
diff --git a/sdks/python/apache_beam/examples/snippets/snippets.py 
b/sdks/python/apache_beam/examples/snippets/snippets.py
index 5155ee4..82d3ecc 100644
--- a/sdks/python/apache_beam/examples/snippets/snippets.py
+++ b/sdks/python/apache_beam/examples/snippets/snippets.py
@@ -31,15 +31,9 @@ string. The tags can contain only letters, digits and _.
 """
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
 import argparse
 import base64
 import json
-from builtins import object
-from builtins import range
 from decimal import Decimal
 
 import apache_beam as beam
diff --git a/sdks/python/apache_beam/examples/snippets/snippets_test.py 
b/sdks/python/apache_beam/examples/snippets/snippets_test.py
index 3ce6f1d..fddb24c 100644
--- a/sdks/python/apache_beam/examples/snippets/snippets_test.py
+++ b/sdks/python/apache_beam/examples/snippets/snippets_test.py
@@ -19,9 +19,6 @@
 """Tests for all code snippets used in public docs."""
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-
 import gc
 import glob
 import gzip
@@ -32,10 +29,6 @@ import tempfile
 import time
 import unittest
 import uuid
-from builtins import map
-from builtins import object
-from builtins import range
-from builtins import zip
 
 import mock
 import parameterized
@@ -355,6 +348,79 @@ class TypeHintsTest(unittest.TestCase):
     with self.assertRaises(typehints.TypeCheckError):
       words_with_lens | beam.Map(lambda x: x).with_input_types(Tuple[int, int])
 
+  def test_bad_types_annotations(self):
+    p = TestPipeline(options=PipelineOptions(pipeline_type_check=True))
+
+    numbers = p | beam.Create(['1', '2', '3'])
+
+    # Consider the following code.
+    # pylint: disable=expression-not-assigned
+    # pylint: disable=unused-variable
+    class FilterEvensDoFn(beam.DoFn):
+      def process(self, element):
+        if element % 2 == 0:
+          yield element
+
+    evens = numbers | 'Untyped Filter' >> beam.ParDo(FilterEvensDoFn())
+
+    # Now suppose numbers was defined as [snippet above].
+    # When running this pipeline, you'd get a runtime error,
+    # possibly on a remote machine, possibly very late.
+
+    with self.assertRaises(TypeError):
+      p.run()
+
+    # To catch this early, we can annotate process() with the expected types.
+    # Beam will then use these as type hints and perform type checking before
+    # the pipeline starts.
+    with self.assertRaises(typehints.TypeCheckError):
+      # [START type_hints_do_fn_annotations]
+      from typing import Iterable
+
+      class FilterEvensDoFn(beam.DoFn):
+        def process(self, element: int) -> Iterable[int]:
+          if element % 2 == 0:
+            yield element
+
+      evens = numbers | 'filter_evens' >> beam.ParDo(FilterEvensDoFn())
+      # [END type_hints_do_fn_annotations]
+
+    # Another example, using a list output type. Notice that the output
+    # annotation has an additional Optional for the else clause.
+    with self.assertRaises(typehints.TypeCheckError):
+      # [START type_hints_do_fn_annotations_optional]
+      from typing import List, Optional
+
+      class FilterEvensDoubleDoFn(beam.DoFn):
+        def process(self, element: int) -> Optional[List[int]]:
+          if element % 2 == 0:
+            return [element, element]
+          return None
+
+      evens = numbers | 'double_evens' >> beam.ParDo(FilterEvensDoubleDoFn())
+      # [END type_hints_do_fn_annotations_optional]
+
+    # Example using an annotated function.
+    with self.assertRaises(typehints.TypeCheckError):
+      # [START type_hints_map_annotations]
+      def my_fn(element: int) -> str:
+        return 'id_' + str(element)
+
+      ids = numbers | 'to_id' >> beam.Map(my_fn)
+      # [END type_hints_map_annotations]
+
+    # Example using an annotated PTransform.
+    with self.assertRaises(typehints.TypeCheckError):
+      # [START type_hints_ptransforms]
+      from apache_beam.pvalue import PCollection
+
+      class IntToStr(beam.PTransform):
+        def expand(self, pcoll: PCollection[int]) -> PCollection[str]:
+          return pcoll | beam.Map(lambda elem: str(elem))
+
+      ids = numbers | 'convert to str' >> IntToStr()
+      # [END type_hints_ptransforms]
+
   def test_runtime_checks_off(self):
     # We do not run the following pipeline, as it has incorrect type
     # information, and may fail with obscure errors, depending on the runner
diff --git a/sdks/python/apache_beam/examples/snippets/snippets_test_py3.py 
b/sdks/python/apache_beam/examples/snippets/snippets_test_py3.py
deleted file mode 100644
index 5eb1d4b..0000000
--- a/sdks/python/apache_beam/examples/snippets/snippets_test_py3.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# coding=utf-8
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""
-Tests for all code snippets used in public docs, using Python 3 specific
-syntax.
-"""
-# pytype: skip-file
-
-from __future__ import absolute_import
-from __future__ import division
-
-import logging
-import unittest
-
-import apache_beam as beam
-from apache_beam import typehints
-from apache_beam.options.pipeline_options import PipelineOptions
-from apache_beam.testing.test_pipeline import TestPipeline
-
-
-class TypeHintsTest(unittest.TestCase):
-  def test_bad_types_annotations(self):
-    p = TestPipeline(options=PipelineOptions(pipeline_type_check=True))
-
-    numbers = p | beam.Create(['1', '2', '3'])
-
-    # Consider the following code.
-    # pylint: disable=expression-not-assigned
-    # pylint: disable=unused-variable
-    class FilterEvensDoFn(beam.DoFn):
-      def process(self, element):
-        if element % 2 == 0:
-          yield element
-
-    evens = numbers | 'Untyped Filter' >> beam.ParDo(FilterEvensDoFn())
-
-    # Now suppose numbers was defined as [snippet above].
-    # When running this pipeline, you'd get a runtime error,
-    # possibly on a remote machine, possibly very late.
-
-    with self.assertRaises(TypeError):
-      p.run()
-
-    # To catch this early, we can annotate process() with the expected types.
-    # Beam will then use these as type hints and perform type checking before
-    # the pipeline starts.
-    with self.assertRaises(typehints.TypeCheckError):
-      # [START type_hints_do_fn_annotations]
-      from typing import Iterable
-
-      class FilterEvensDoFn(beam.DoFn):
-        def process(self, element: int) -> Iterable[int]:
-          if element % 2 == 0:
-            yield element
-
-      evens = numbers | 'filter_evens' >> beam.ParDo(FilterEvensDoFn())
-      # [END type_hints_do_fn_annotations]
-
-    # Another example, using a list output type. Notice that the output
-    # annotation has an additional Optional for the else clause.
-    with self.assertRaises(typehints.TypeCheckError):
-      # [START type_hints_do_fn_annotations_optional]
-      from typing import List, Optional
-
-      class FilterEvensDoubleDoFn(beam.DoFn):
-        def process(self, element: int) -> Optional[List[int]]:
-          if element % 2 == 0:
-            return [element, element]
-          return None
-
-      evens = numbers | 'double_evens' >> beam.ParDo(FilterEvensDoubleDoFn())
-      # [END type_hints_do_fn_annotations_optional]
-
-    # Example using an annotated function.
-    with self.assertRaises(typehints.TypeCheckError):
-      # [START type_hints_map_annotations]
-      def my_fn(element: int) -> str:
-        return 'id_' + str(element)
-
-      ids = numbers | 'to_id' >> beam.Map(my_fn)
-      # [END type_hints_map_annotations]
-
-    # Example using an annotated PTransform.
-    with self.assertRaises(typehints.TypeCheckError):
-      # [START type_hints_ptransforms]
-      from apache_beam.pvalue import PCollection
-
-      class IntToStr(beam.PTransform):
-        def expand(self, pcoll: PCollection[int]) -> PCollection[str]:
-          return pcoll | beam.Map(lambda elem: str(elem))
-
-      ids = numbers | 'convert to str' >> IntToStr()
-      # [END type_hints_ptransforms]
-
-
-if __name__ == '__main__':
-  logging.getLogger().setLevel(logging.INFO)
-  unittest.main()
diff --git a/sdks/python/apache_beam/examples/snippets/transforms/__init__.py 
b/sdks/python/apache_beam/examples/snippets/transforms/__init__.py
index 6569e3f..cce3aca 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/__init__.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/__init__.py
@@ -14,5 +14,3 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-from __future__ import absolute_import
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/__init__.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/__init__.py
index 6569e3f..cce3aca 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/__init__.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/__init__.py
@@ -14,5 +14,3 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-from __future__ import absolute_import
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey.py
index b20cd51..ae5ce81 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def cogroupbykey(test=None):
   # [START cogroupbykey]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey_test.py
index cccfbe3..ad4ed99 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/cogroupbykey_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally.py
index 15d1693..eb1ea97 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally.py
@@ -18,10 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
 
 def combineglobally_function(test=None):
   # [START combineglobally_function]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally_test.py
index 3075388..e3c36a4 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey.py
index 2b837ac..3116969 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey.py
@@ -18,10 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
 
 def combineperkey_simple(test=None):
   # [START combineperkey_simple]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey_test.py
index ec23167..990781b 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues.py
index 97d7c4c..c9333f5 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues.py
@@ -18,10 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
 
 def combinevalues_simple(test=None):
   # [START combinevalues_simple]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues_test.py
index 3e233c9..dd4da75 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count.py
index 6ee3980..de7021b 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def count_globally(test=None):
   # [START count_globally]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count_test.py
index fff2406..9016300 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/count_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct.py
index e2ee6da..1d2f968 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def distinct(test=None):
   # [START distinct]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct_test.py
index 70d1341..6f1246e 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/distinct_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_test.py
index 029d9d5..dfeeaad 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_test.py
@@ -21,10 +21,6 @@
 # Wrapping hurts the readability of the docs.
 # pylint: disable=line-too-long
 
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
 import typing
 import unittest
 
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py
index 70f49f5..4abdeae 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def groupbykey(test=None):
   # [START groupbykey]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey_test.py
index 3ea278c..1a9b8f1 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches.py
index 5e6ceaa..70b3144 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def groupintobatches(test=None):
   # [START groupintobatches]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches_test.py
index 76c94da..09449f7 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches_test.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py
index 1665518..d7184c0 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def latest_globally(test=None):
   # [START latest_globally]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest_test.py
index 6f9bffd..58ad920 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max.py
index fd0187f..1d17c34 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def max_globally(test=None):
   # [START max_globally]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max_test.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max_test.py
index af43781..834129a 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/max_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean.py
index 033c0cf..489655b 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def mean_globally(test=None):
   # [START mean_globally]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean_test.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean_test.py
index 796bbbf..d91f9f2 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min.py
index 812e733..f31ce4a 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def min_globally(test=None):
   # [START min_globally]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min_test.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min_test.py
index 321fd12..c30a2bd 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/min_test.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample.py
index 1ca8273..92fc6a3 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def sample_fixed_size_globally(test=None):
   # [START sample_fixed_size_globally]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample_test.py
index bb337ee..453d82a 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum.py
index 74b0836..a255092 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def sum_globally(test=None):
   # [START sum_globally]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum_test.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum_test.py
index dd59770..1516739 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum_test.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top.py
index 8b6cfa6..787ab9b 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def top_largest(test=None):
   # [START top_largest]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top_test.py 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top_test.py
index 4781d81..95beb24 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/top_test.py
@@ -16,9 +16,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/__init__.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/__init__.py
index 6569e3f..cce3aca 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/__init__.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/__init__.py
@@ -14,5 +14,3 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-from __future__ import absolute_import
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter.py
index 04cf58e..123e334 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def filter_function(test=None):
   # [START filter_function]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_test.py
index 10ad79d..81023c6 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap.py
index 7e3e007..3628285 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def flatmap_simple(test=None):
   # [START flatmap_simple]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap_test.py
index 9e67e74..23e6d22 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys.py
index 9bbe952..af206e0 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def keys(test=None):
   # [START keys]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys_test.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys_test.py
index 9455836..fcfe370 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap.py
index 8e69bc6..0fc77e9 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def kvswap(test=None):
   # [START kvswap]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap_test.py
index c3eed27..fa49431 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/kvswap_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map.py
index eaac277..216cd5b 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def map_simple(test=None):
   # [START map_simple]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map_test.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map_test.py
index 2f34a62..423d057 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/map_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo.py
index 965446f..c54d05e 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def pardo_dofn(test=None):
   # [START pardo_dofn]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo_test.py
index 9882cd4..7a6f2ce 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 from io import StringIO
 
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition.py
index ba1e8a7..30dc8e3 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def partition_function(test=None):
   # pylint: disable=line-too-long, expression-not-assigned
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition_test.py
index be243b2..55babe0 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex.py
index cdd83a5..68688b8 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def regex_matches(test=None):
   # [START regex_matches]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_test.py
index d783b1f..1cc7549 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring.py
index 32755cb..7ca9d2b 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def tostring_kvs(test=None):
   # [START tostring_kvs]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring_test.py
index e142278..01b9c04 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values.py 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values.py
index a9b3cc1..c72c404 100644
--- a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values.py
+++ b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def values(test=None):
   # [START values]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values_test.py
index 6c2caaa..acd8421 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/values_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps.py
index bf4a4d4..5008f26 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 
 def withtimestamps_event_time(test=None):
   # [START withtimestamps_event_time]
diff --git 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps_test.py
 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps_test.py
index 191d114..f23f48b 100644
--- 
a/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps_test.py
+++ 
b/sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps_test.py
@@ -18,9 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-from __future__ import print_function
-
 import unittest
 
 import mock
diff --git a/sdks/python/apache_beam/examples/snippets/util.py 
b/sdks/python/apache_beam/examples/snippets/util.py
index a14cd36..7911b32 100644
--- a/sdks/python/apache_beam/examples/snippets/util.py
+++ b/sdks/python/apache_beam/examples/snippets/util.py
@@ -17,8 +17,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import ast
 import shlex
 import subprocess as sp
diff --git a/sdks/python/apache_beam/examples/snippets/util_test.py 
b/sdks/python/apache_beam/examples/snippets/util_test.py
index 21d4e0e..fae26a3 100644
--- a/sdks/python/apache_beam/examples/snippets/util_test.py
+++ b/sdks/python/apache_beam/examples/snippets/util_test.py
@@ -18,8 +18,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
 
 from mock import patch
diff --git a/sdks/python/apache_beam/examples/sql_taxi.py 
b/sdks/python/apache_beam/examples/sql_taxi.py
index 32fd80a..165bbc9 100644
--- a/sdks/python/apache_beam/examples/sql_taxi.py
+++ b/sdks/python/apache_beam/examples/sql_taxi.py
@@ -29,8 +29,6 @@ Docker must also be available to run this pipeline locally.
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import json
 import logging
 
diff --git a/sdks/python/apache_beam/examples/streaming_wordcount.py 
b/sdks/python/apache_beam/examples/streaming_wordcount.py
index 14d7e8c..d276cfc 100644
--- a/sdks/python/apache_beam/examples/streaming_wordcount.py
+++ b/sdks/python/apache_beam/examples/streaming_wordcount.py
@@ -20,13 +20,9 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 
-from past.builtins import unicode
-
 import apache_beam as beam
 import apache_beam.transforms.window as window
 from apache_beam.examples.wordcount_with_metrics import WordExtractingDoFn
@@ -85,8 +81,7 @@ def run(argv=None, save_main_session=True):
 
     counts = (
         lines
-        | 'split' >>
-        (beam.ParDo(WordExtractingDoFn()).with_output_types(unicode))
+        | 'split' >> (beam.ParDo(WordExtractingDoFn()).with_output_types(str))
         | 'pair_with_one' >> beam.Map(lambda x: (x, 1))
         | beam.WindowInto(window.FixedWindows(15, 0))
         | 'group' >> beam.GroupByKey()
diff --git a/sdks/python/apache_beam/examples/streaming_wordcount_debugging.py 
b/sdks/python/apache_beam/examples/streaming_wordcount_debugging.py
index 28d9df9..2df87f4 100644
--- a/sdks/python/apache_beam/examples/streaming_wordcount_debugging.py
+++ b/sdks/python/apache_beam/examples/streaming_wordcount_debugging.py
@@ -34,15 +34,11 @@ gcloud alpha pubsub topics publish $PUBSUB_INPUT_TOPIC 
--message '210 213 151'
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 import re
 import time
 
-from past.builtins import unicode
-
 import apache_beam as beam
 import apache_beam.transforms.window as window
 from apache_beam.examples.wordcount import WordExtractingDoFn
@@ -132,8 +128,7 @@ def run(argv=None, save_main_session=True):
 
     counts = (
         lines
-        | 'Split' >>
-        (beam.ParDo(WordExtractingDoFn()).with_output_types(unicode))
+        | 'Split' >> (beam.ParDo(WordExtractingDoFn()).with_output_types(str))
         | 'AddTimestampFn' >> beam.ParDo(AddTimestampFn())
         | 'After AddTimestampFn' >> ParDo(PrintFn('After AddTimestampFn'))
         | 'PairWithOne' >> beam.Map(lambda x: (x, 1))
diff --git 
a/sdks/python/apache_beam/examples/streaming_wordcount_debugging_it_test.py 
b/sdks/python/apache_beam/examples/streaming_wordcount_debugging_it_test.py
index 526863d..367fc82 100644
--- a/sdks/python/apache_beam/examples/streaming_wordcount_debugging_it_test.py
+++ b/sdks/python/apache_beam/examples/streaming_wordcount_debugging_it_test.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import logging
 import unittest
 import uuid
diff --git 
a/sdks/python/apache_beam/examples/streaming_wordcount_debugging_test.py 
b/sdks/python/apache_beam/examples/streaming_wordcount_debugging_test.py
index 1210c48..2ab8099 100644
--- a/sdks/python/apache_beam/examples/streaming_wordcount_debugging_test.py
+++ b/sdks/python/apache_beam/examples/streaming_wordcount_debugging_test.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import unittest
 
 import mock
diff --git a/sdks/python/apache_beam/examples/streaming_wordcount_it_test.py 
b/sdks/python/apache_beam/examples/streaming_wordcount_it_test.py
index cd79ddf..7812283 100644
--- a/sdks/python/apache_beam/examples/streaming_wordcount_it_test.py
+++ b/sdks/python/apache_beam/examples/streaming_wordcount_it_test.py
@@ -19,12 +19,9 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import logging
 import unittest
 import uuid
-from builtins import range
 
 from hamcrest.core.core.allof import all_of
 from nose.plugins.attrib import attr
diff --git a/sdks/python/apache_beam/examples/windowed_wordcount.py 
b/sdks/python/apache_beam/examples/windowed_wordcount.py
index a93c075..88e6461 100644
--- a/sdks/python/apache_beam/examples/windowed_wordcount.py
+++ b/sdks/python/apache_beam/examples/windowed_wordcount.py
@@ -23,13 +23,9 @@ and is not yet available for use.
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 
-from past.builtins import unicode
-
 import apache_beam as beam
 import apache_beam.transforms.window as window
 
@@ -84,7 +80,7 @@ def run(argv=None):
 
     transformed = (
         lines
-        | 'Split' >> (beam.FlatMap(find_words).with_output_types(unicode))
+        | 'Split' >> (beam.FlatMap(find_words).with_output_types(str))
         | 'PairWithOne' >> beam.Map(lambda x: (x, 1))
         | beam.WindowInto(window.FixedWindows(2 * 60, 0))
         | 'Group' >> beam.GroupByKey()
diff --git a/sdks/python/apache_beam/examples/wordcount.py 
b/sdks/python/apache_beam/examples/wordcount.py
index aa07802..b59baa6 100644
--- a/sdks/python/apache_beam/examples/wordcount.py
+++ b/sdks/python/apache_beam/examples/wordcount.py
@@ -19,14 +19,10 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 import re
 
-from past.builtins import unicode
-
 import apache_beam as beam
 from apache_beam.io import ReadFromText
 from apache_beam.io import WriteToText
@@ -78,8 +74,7 @@ def run(argv=None, save_main_session=True):
 
     counts = (
         lines
-        | 'Split' >>
-        (beam.ParDo(WordExtractingDoFn()).with_output_types(unicode))
+        | 'Split' >> (beam.ParDo(WordExtractingDoFn()).with_output_types(str))
         | 'PairWIthOne' >> beam.Map(lambda x: (x, 1))
         | 'GroupAndSum' >> beam.CombinePerKey(sum))
 
diff --git a/sdks/python/apache_beam/examples/wordcount_dataframe.py 
b/sdks/python/apache_beam/examples/wordcount_dataframe.py
index 384f6f5..8eb240b 100644
--- a/sdks/python/apache_beam/examples/wordcount_dataframe.py
+++ b/sdks/python/apache_beam/examples/wordcount_dataframe.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 
diff --git a/sdks/python/apache_beam/examples/wordcount_dataframe_test.py 
b/sdks/python/apache_beam/examples/wordcount_dataframe_test.py
index cffaf9a..aa2fcc5 100644
--- a/sdks/python/apache_beam/examples/wordcount_dataframe_test.py
+++ b/sdks/python/apache_beam/examples/wordcount_dataframe_test.py
@@ -20,8 +20,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import collections
 import logging
 import re
diff --git a/sdks/python/apache_beam/examples/wordcount_debugging.py 
b/sdks/python/apache_beam/examples/wordcount_debugging.py
index 19f511e..d4195df 100644
--- a/sdks/python/apache_beam/examples/wordcount_debugging.py
+++ b/sdks/python/apache_beam/examples/wordcount_debugging.py
@@ -42,14 +42,10 @@ and an output prefix on GCS::
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 import re
 
-from past.builtins import unicode
-
 import apache_beam as beam
 from apache_beam.io import ReadFromText
 from apache_beam.io import WriteToText
@@ -107,8 +103,8 @@ class CountWords(beam.PTransform):
     return (
         pcoll
         | 'split' >> (
-            beam.FlatMap(lambda x: re.findall(r'[A-Za-z\']+', x)).
-            with_output_types(unicode))
+            beam.FlatMap(
+                lambda x: re.findall(r'[A-Za-z\']+', 
x)).with_output_types(str))
         | 'pair_with_one' >> beam.Map(lambda x: (x, 1))
         | 'group' >> beam.GroupByKey()
         | 'count' >> beam.Map(count_ones))
diff --git a/sdks/python/apache_beam/examples/wordcount_debugging_test.py 
b/sdks/python/apache_beam/examples/wordcount_debugging_test.py
index c92df6d..4c8a62a 100644
--- a/sdks/python/apache_beam/examples/wordcount_debugging_test.py
+++ b/sdks/python/apache_beam/examples/wordcount_debugging_test.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import logging
 import re
 import tempfile
diff --git a/sdks/python/apache_beam/examples/wordcount_it_test.py 
b/sdks/python/apache_beam/examples/wordcount_it_test.py
index 317b5c6..24c455b 100644
--- a/sdks/python/apache_beam/examples/wordcount_it_test.py
+++ b/sdks/python/apache_beam/examples/wordcount_it_test.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import logging
 import os
 import time
diff --git a/sdks/python/apache_beam/examples/wordcount_minimal.py 
b/sdks/python/apache_beam/examples/wordcount_minimal.py
index a4f7057..1a16706 100644
--- a/sdks/python/apache_beam/examples/wordcount_minimal.py
+++ b/sdks/python/apache_beam/examples/wordcount_minimal.py
@@ -46,14 +46,10 @@ pipeline. You can see the results in your output bucket in 
the GCS browser.
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 import re
 
-from past.builtins import unicode
-
 import apache_beam as beam
 from apache_beam.io import ReadFromText
 from apache_beam.io import WriteToText
@@ -111,8 +107,8 @@ def run(argv=None, save_main_session=True):
     counts = (
         lines
         | 'Split' >> (
-            beam.FlatMap(lambda x: re.findall(r'[A-Za-z\']+', x)).
-            with_output_types(unicode))
+            beam.FlatMap(
+                lambda x: re.findall(r'[A-Za-z\']+', 
x)).with_output_types(str))
         | 'PairWithOne' >> beam.Map(lambda x: (x, 1))
         | 'GroupAndSum' >> beam.CombinePerKey(sum))
 
diff --git a/sdks/python/apache_beam/examples/wordcount_minimal_test.py 
b/sdks/python/apache_beam/examples/wordcount_minimal_test.py
index a966401..f964f1f 100644
--- a/sdks/python/apache_beam/examples/wordcount_minimal_test.py
+++ b/sdks/python/apache_beam/examples/wordcount_minimal_test.py
@@ -19,8 +19,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import collections
 import logging
 import re
diff --git a/sdks/python/apache_beam/examples/wordcount_test.py 
b/sdks/python/apache_beam/examples/wordcount_test.py
index 51c0bc4..e3d476d 100644
--- a/sdks/python/apache_beam/examples/wordcount_test.py
+++ b/sdks/python/apache_beam/examples/wordcount_test.py
@@ -20,8 +20,6 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import collections
 import logging
 import re
diff --git a/sdks/python/apache_beam/examples/wordcount_with_metrics.py 
b/sdks/python/apache_beam/examples/wordcount_with_metrics.py
index 6732568..25dc73e 100644
--- a/sdks/python/apache_beam/examples/wordcount_with_metrics.py
+++ b/sdks/python/apache_beam/examples/wordcount_with_metrics.py
@@ -19,14 +19,10 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 import re
 
-from past.builtins import unicode
-
 import apache_beam as beam
 from apache_beam.io import ReadFromText
 from apache_beam.io import WriteToText
@@ -101,8 +97,7 @@ def run(argv=None, save_main_session=True):
 
   counts = (
       lines
-      | 'split' >>
-      (beam.ParDo(WordExtractingDoFn()).with_output_types(unicode))
+      | 'split' >> (beam.ParDo(WordExtractingDoFn()).with_output_types(str))
       | 'pair_with_one' >> beam.Map(lambda x: (x, 1))
       | 'group' >> beam.GroupByKey()
       | 'count' >> beam.Map(count_ones))
diff --git a/sdks/python/apache_beam/examples/wordcount_xlang.py 
b/sdks/python/apache_beam/examples/wordcount_xlang.py
index 88690e7..80a0c8f 100644
--- a/sdks/python/apache_beam/examples/wordcount_xlang.py
+++ b/sdks/python/apache_beam/examples/wordcount_xlang.py
@@ -19,15 +19,12 @@
 
 # pytype: skip-file
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 import re
 import subprocess
 
 import grpc
-from past.builtins import unicode
 
 import apache_beam as beam
 from apache_beam.io import ReadFromText
@@ -63,8 +60,7 @@ def build_pipeline(p, input_file, output_file):
 
   counts = (
       lines
-      | 'split' >>
-      (beam.ParDo(WordExtractingDoFn()).with_output_types(unicode))
+      | 'split' >> (beam.ParDo(WordExtractingDoFn()).with_output_types(str))
       | 'count' >> beam.ExternalTransform(
           'beam:transforms:xlang:count', None, EXPANSION_SERVICE_ADDR))
 
diff --git a/sdks/python/apache_beam/examples/wordcount_xlang_sql.py 
b/sdks/python/apache_beam/examples/wordcount_xlang_sql.py
index 28f58a3..97a43d3 100644
--- a/sdks/python/apache_beam/examples/wordcount_xlang_sql.py
+++ b/sdks/python/apache_beam/examples/wordcount_xlang_sql.py
@@ -22,15 +22,11 @@ Java 8 must be available to run this pipeline, and the
 Docker must also be available to run this pipeline locally.
 """
 
-from __future__ import absolute_import
-
 import argparse
 import logging
 import re
 import typing
 
-from past.builtins import unicode
-
 import apache_beam as beam
 from apache_beam import coders
 from apache_beam.io import ReadFromText
@@ -44,9 +40,9 @@ from apache_beam.transforms.sql import SqlTransform
 # One way to create such a PCollection is to produce a PCollection of
 # NamedTuple registered with the RowCoder.
 #
-# Here we create and register a simple NamedTuple with a single unicode typed
+# Here we create and register a simple NamedTuple with a single str typed
 # field named 'word' which we will use below.
-MyRow = typing.NamedTuple('MyRow', [('word', unicode)])
+MyRow = typing.NamedTuple('MyRow', [('word', str)])
 coders.registry.register_coder(MyRow, coders.RowCoder)
 
 

Reply via email to