From f936d540e1811967bd3cc819089b498b98b1e1be Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Mon, 25 Sep 2023 17:13:00 +0000 Subject: [PATCH] Remove __future__ imports All __future__ imports (unicode_literals, print_function) are already mandatory in py3. Also remove an outdated py2 comment in presubmit_canned_checks.py Bug: 1475402 Change-Id: I27cf6a8268f6dd1081f22af782c4c29a975376ae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4867135 Reviewed-by: Josip Sokcevic Commit-Queue: Gavin Mak --- auth.py | 2 -- clang_format.py | 2 -- compile_single_file.py | 2 -- detect_host_arch.py | 2 -- download_from_google_storage.py | 2 -- fetch.py | 2 -- fetch_configs/config_util.py | 2 -- fix_encoding.py | 2 -- gn.py | 2 -- gsutil.py | 2 -- lockfile.py | 2 -- man/src/filter_demo_output.py | 2 -- metadata/scan.py | 2 -- metrics.py | 2 -- metrics_utils.py | 2 -- my_activity.py | 2 -- ninjalog_uploader_wrapper.py | 2 -- owners_finder.py | 2 -- presubmit_canned_checks.py | 5 ----- presubmit_support.py | 2 -- pylint_main.py | 2 -- repo_launcher | 2 -- roll_dep.py | 2 -- setup_color.py | 2 -- split_cl.py | 2 -- testing_support/coverage_utils.py | 2 -- testing_support/fake_repos.py | 2 -- testing_support/test_case_utils.py | 2 -- testing_support/trial_dir.py | 2 -- tests/download_from_google_storage_unittest.py | 2 -- tests/fix_encoding_test.py | 2 -- tests/gclient_scm_test.py | 2 -- tests/gsutil_test.py | 2 -- tests/presubmit_unittest.py | 2 -- tests/rdb_wrapper_test.py | 2 -- upload_to_google_storage.py | 2 -- watchlists.py | 2 -- weekly | 2 -- win_toolchain/get_toolchain_if_necessary.py | 2 -- win_toolchain/package_from_installed.py | 2 -- wtf | 2 -- 41 files changed, 85 deletions(-) diff --git a/auth.py b/auth.py index 5696a7ac5..08aeeefca 100644 --- a/auth.py +++ b/auth.py @@ -3,8 +3,6 @@ # found in the LICENSE file. """Google OAuth2 related functions.""" -from __future__ import print_function - import collections import datetime import functools diff --git a/clang_format.py b/clang_format.py index bfe3b4b47..c32995e42 100755 --- a/clang_format.py +++ b/clang_format.py @@ -8,8 +8,6 @@ clang-format binaries are pulled down from Google Cloud Storage whenever you sync Chrome, to platform-specific locations. This script knows how to locate those tools, assuming the script is invoked from inside a Chromium checkout.""" -from __future__ import print_function - import gclient_paths import os import subprocess diff --git a/compile_single_file.py b/compile_single_file.py index b766e0073..8af9ce140 100644 --- a/compile_single_file.py +++ b/compile_single_file.py @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import argparse import os import subprocess diff --git a/detect_host_arch.py b/detect_host_arch.py index 94e2572aa..7669d9ec8 100755 --- a/detect_host_arch.py +++ b/detect_host_arch.py @@ -4,8 +4,6 @@ # found in the LICENSE file. """Outputs host CPU architecture in format recognized by gyp.""" -from __future__ import print_function - import platform import re diff --git a/download_from_google_storage.py b/download_from_google_storage.py index ff114f07b..0af4fd7f6 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -4,8 +4,6 @@ # found in the LICENSE file. """Download files from Google Storage based on SHA1 sums.""" -from __future__ import print_function - import hashlib import optparse import os diff --git a/fetch.py b/fetch.py index fcfdf781f..cd4a4641d 100755 --- a/fetch.py +++ b/fetch.py @@ -17,8 +17,6 @@ Optional arguments may be passed on the command line in key-value pairs. These parameters will be passed through to the config's main method. """ -from __future__ import print_function - import json import argparse import os diff --git a/fetch_configs/config_util.py b/fetch_configs/config_util.py index e1808fdf8..6729a4dc3 100644 --- a/fetch_configs/config_util.py +++ b/fetch_configs/config_util.py @@ -3,8 +3,6 @@ # found in the LICENSE file. """This module holds utilities which make writing configs easier.""" -from __future__ import print_function - import json diff --git a/fix_encoding.py b/fix_encoding.py index 21efb938c..f23bda7bf 100644 --- a/fix_encoding.py +++ b/fix_encoding.py @@ -5,8 +5,6 @@ multiple platforms with python. """ -from __future__ import print_function - import codecs import locale import os diff --git a/gn.py b/gn.py index 96e01d3f7..296042ed4 100755 --- a/gn.py +++ b/gn.py @@ -11,8 +11,6 @@ binary. It will also automatically try to find the gn binary when run inside the chrome source tree, so users can just type "gn" on the command line (normally depot_tools is on the path).""" -from __future__ import print_function - import gclient_paths import os import subprocess diff --git a/gsutil.py b/gsutil.py index 1e90f5661..4dcb2d617 100755 --- a/gsutil.py +++ b/gsutil.py @@ -4,8 +4,6 @@ # found in the LICENSE file. """Run a pinned gsutil.""" -from __future__ import print_function - import argparse import base64 import contextlib diff --git a/lockfile.py b/lockfile.py index 3cd567036..3eedae172 100644 --- a/lockfile.py +++ b/lockfile.py @@ -3,8 +3,6 @@ # found in the LICENSE file. """Exclusive filelocking for all supported platforms.""" -from __future__ import print_function - import contextlib import logging import os diff --git a/man/src/filter_demo_output.py b/man/src/filter_demo_output.py index 3222064d5..d7b55abd8 100755 --- a/man/src/filter_demo_output.py +++ b/man/src/filter_demo_output.py @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import collections import os import re diff --git a/metadata/scan.py b/metadata/scan.py index eaf796c7d..9fac9e3fd 100644 --- a/metadata/scan.py +++ b/metadata/scan.py @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import argparse from collections import defaultdict import os diff --git a/metrics.py b/metrics.py index 3ccbfc9a1..5645f2858 100644 --- a/metrics.py +++ b/metrics.py @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import contextlib import functools import json diff --git a/metrics_utils.py b/metrics_utils.py index 0664e3969..ee7bb3212 100644 --- a/metrics_utils.py +++ b/metrics_utils.py @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import re import os import scm diff --git a/my_activity.py b/my_activity.py index b1824dba6..e30849170 100755 --- a/my_activity.py +++ b/my_activity.py @@ -32,8 +32,6 @@ To add additional gerrit instances, one can pass a JSON file as parameter: # check those details to determine if there was activity in the given period. # This means that query time scales mostly with (today() - begin). -from __future__ import print_function - import collections import contextlib from datetime import datetime diff --git a/ninjalog_uploader_wrapper.py b/ninjalog_uploader_wrapper.py index ca4dcf65e..7a06826e1 100755 --- a/ninjalog_uploader_wrapper.py +++ b/ninjalog_uploader_wrapper.py @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import json import os import platform diff --git a/owners_finder.py b/owners_finder.py index 3d6096f43..b258b4320 100644 --- a/owners_finder.py +++ b/owners_finder.py @@ -3,8 +3,6 @@ # found in the LICENSE file. """Interactive tool for finding reviewers/owners for a change.""" -from __future__ import print_function - import os import copy diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 2aa03e872..5f0621341 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -3,8 +3,6 @@ # found in the LICENSE file. """Generic presubmit checks that can be reused by other presubmit checks.""" -from __future__ import print_function - import io as _io import os as _os import zlib @@ -1123,9 +1121,6 @@ def GetPythonUnitTests(input_api, output_api, unit_tests, python3=False): '.', input_api.os_path.pathsep.join(['..'] * (cwd.count('/') + 1)) ] - # We convert to str, since on Windows on Python 2 only strings are - # allowed as environment variables, but literals are unicode since - # we're importing unicode_literals from __future__. if env.get('PYTHONPATH'): backpath.append(env.get('PYTHONPATH')) env['PYTHONPATH'] = input_api.os_path.pathsep.join((backpath)) diff --git a/presubmit_support.py b/presubmit_support.py index b986b7bc7..fe21b398c 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -5,8 +5,6 @@ """Enables directory-specific presubmit checks to run at upload and/or commit. """ -from __future__ import print_function - __version__ = '2.0.0' # TODO(joi) Add caching where appropriate/needed. The API is designed to allow diff --git a/pylint_main.py b/pylint_main.py index e9717ebb0..f72e4e41b 100755 --- a/pylint_main.py +++ b/pylint_main.py @@ -7,8 +7,6 @@ This will be executed by vpython with the right pylint versions. """ -from __future__ import print_function - import os import sys diff --git a/repo_launcher b/repo_launcher index d2a4df2ed..5791e1c7b 100755 --- a/repo_launcher +++ b/repo_launcher @@ -22,8 +22,6 @@ It is used to get an initial repo client checkout, and after that it runs the copy of repo in the checkout. """ -from __future__ import print_function - import datetime import os import platform diff --git a/roll_dep.py b/roll_dep.py index fc15c6a4d..dbd50f208 100755 --- a/roll_dep.py +++ b/roll_dep.py @@ -8,8 +8,6 @@ Works only with git checkout and git dependencies. Currently this script will always roll to the tip of to origin/main. """ -from __future__ import print_function - import argparse import itertools import os diff --git a/setup_color.py b/setup_color.py index af039c82a..040b763c8 100644 --- a/setup_color.py +++ b/setup_color.py @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import ctypes import platform import subprocess diff --git a/split_cl.py b/split_cl.py index 70768755c..a4e2007de 100644 --- a/split_cl.py +++ b/split_cl.py @@ -4,8 +4,6 @@ # found in the LICENSE file. """Splits a branch into smaller branches and uploads CLs.""" -from __future__ import print_function - import collections import os import re diff --git a/testing_support/coverage_utils.py b/testing_support/coverage_utils.py index 0fefab3e5..f07ddcac5 100644 --- a/testing_support/coverage_utils.py +++ b/testing_support/coverage_utils.py @@ -2,8 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import distutils.version import os import sys diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py index 06f3c3528..5f1a44e6b 100755 --- a/testing_support/fake_repos.py +++ b/testing_support/fake_repos.py @@ -5,8 +5,6 @@ # found in the LICENSE file. """Generate fake repositories for testing.""" -from __future__ import print_function - import atexit import datetime import errno diff --git a/testing_support/test_case_utils.py b/testing_support/test_case_utils.py index 3747041c6..b379bfe54 100644 --- a/testing_support/test_case_utils.py +++ b/testing_support/test_case_utils.py @@ -3,8 +3,6 @@ # found in the LICENSE file. """Simplify unit tests based on pymox.""" -from __future__ import print_function - import os import random import string diff --git a/testing_support/trial_dir.py b/testing_support/trial_dir.py index 72e1d131b..0c24a8ea3 100644 --- a/testing_support/trial_dir.py +++ b/testing_support/trial_dir.py @@ -2,8 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from __future__ import print_function - import atexit import logging import os diff --git a/tests/download_from_google_storage_unittest.py b/tests/download_from_google_storage_unittest.py index 0716c1e27..512283334 100755 --- a/tests/download_from_google_storage_unittest.py +++ b/tests/download_from_google_storage_unittest.py @@ -5,8 +5,6 @@ # pylint: disable=protected-access """Unit tests for download_from_google_storage.py.""" -from __future__ import print_function - import optparse import os import queue diff --git a/tests/fix_encoding_test.py b/tests/fix_encoding_test.py index 521ffcc94..4c9c5438d 100755 --- a/tests/fix_encoding_test.py +++ b/tests/fix_encoding_test.py @@ -5,8 +5,6 @@ # found in the LICENSE file. """Unit tests for fix_encoding.py.""" -from __future__ import print_function - import os import sys import unittest diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index c2004e3d5..e90f25d6c 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -6,8 +6,6 @@ # pylint: disable=E1103 -from __future__ import unicode_literals - from io import StringIO import json import logging diff --git a/tests/gsutil_test.py b/tests/gsutil_test.py index d1665beee..39e09187e 100755 --- a/tests/gsutil_test.py +++ b/tests/gsutil_test.py @@ -4,8 +4,6 @@ # found in the LICENSE file. """Test gsutil.py.""" -from __future__ import unicode_literals - import base64 import hashlib import io diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index dcccff39d..ec2dc8891 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -6,8 +6,6 @@ # pylint: disable=no-member,E1103 -from __future__ import unicode_literals - import functools import io import itertools diff --git a/tests/rdb_wrapper_test.py b/tests/rdb_wrapper_test.py index 83c547939..1cdf60ab6 100755 --- a/tests/rdb_wrapper_test.py +++ b/tests/rdb_wrapper_test.py @@ -4,8 +4,6 @@ # found in the LICENSE file. """Unit tests for rdb_wrapper.py""" -from __future__ import print_function - import contextlib import json import logging diff --git a/upload_to_google_storage.py b/upload_to_google_storage.py index bf6d392b4..b8a7857cf 100755 --- a/upload_to_google_storage.py +++ b/upload_to_google_storage.py @@ -4,8 +4,6 @@ # found in the LICENSE file. """Uploads files to Google Storage content addressed.""" -from __future__ import print_function - import hashlib import optparse import os diff --git a/watchlists.py b/watchlists.py index 7c6d776d6..3567cb396 100755 --- a/watchlists.py +++ b/watchlists.py @@ -17,8 +17,6 @@ the watchers for files given on the command line. This is useful to verify changes to WATCHLISTS files. """ -from __future__ import print_function - import logging import os import re diff --git a/weekly b/weekly index 431440205..2b96a4ed8 100755 --- a/weekly +++ b/weekly @@ -5,8 +5,6 @@ """Display log of checkins of one particular developer since a particular date. Only works on git dependencies at the moment.""" -from __future__ import print_function - import gclient_utils import optparse import os diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py index 7942f9a11..a1d10082a 100755 --- a/win_toolchain/get_toolchain_if_necessary.py +++ b/win_toolchain/get_toolchain_if_necessary.py @@ -17,8 +17,6 @@ the toolchain. This is likely to be a poorly tested code path that probably won't be properly maintained. See http://crbug.com/323300. """ -from __future__ import print_function - import argparse from contextlib import closing import hashlib diff --git a/win_toolchain/package_from_installed.py b/win_toolchain/package_from_installed.py index 2567b926f..a8b12730b 100644 --- a/win_toolchain/package_from_installed.py +++ b/win_toolchain/package_from_installed.py @@ -30,8 +30,6 @@ useful as the resulting zip can't be redistributed, and most will presumably have a Pro license anyway). """ -from __future__ import print_function - import collections import glob import json diff --git a/wtf b/wtf index 3ac4c5792..f8743908d 100755 --- a/wtf +++ b/wtf @@ -4,8 +4,6 @@ # found in the LICENSE file. """Display active git branches and code changes in a chromiumos workspace.""" -from __future__ import print_function - import gclient_utils import os import re