[NFC] Remove Python 2 imports from __future__ (#42086)

The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
This commit is contained in:
Daniel Duan
2022-04-13 14:01:30 -07:00
committed by GitHub
parent b5ed5f8140
commit 3dfc40898c
171 changed files with 104 additions and 347 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ===--- Benchmark_DTrace.in ---------------------------------------------===//
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ===--- Benchmark_Driver ------------------------------------------------===//

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ===--- Benchmark_GuardMalloc.in ----------------------------------------===//
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ===--- Benchmark_QuickCheck.in -----------------------------------------===//
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ===--- Benchmark_RuntimeLeaksRunner.in ---------------------------------===//
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import argparse
import os

View File

@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import argparse
import os

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ===--- compare_perf_tests.py -------------------------------------------===//
@@ -27,8 +27,6 @@ class `ReportFormatter` creates the test comparison report in specified format.
"""
from __future__ import print_function
import argparse
import functools
import re

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import argparse
import os

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ===--- generate_harness.py ---------------------------------------------===//
#
@@ -14,8 +14,6 @@
# Generate boilerplate, CMakeLists.txt and utils/main.swift from templates.
from __future__ import print_function
import argparse
import os
import subprocess

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ===--- perf_test_driver.py ---------------------------------------------===//
#
@@ -12,8 +12,6 @@
#
# ===---------------------------------------------------------------------===//
from __future__ import print_function
import functools
import glob
import multiprocessing

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ===--- run_smoke_bench -------------------------------------------------===//
@@ -21,8 +21,6 @@
#
# ===---------------------------------------------------------------------===//
from __future__ import print_function
import argparse
import glob
import os

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ===--- test_Benchmark_Driver.py ----------------------------------------===//

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ===--- test_compare_perf_tests.py --------------------------------------===//

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ===--- test_utils.py ---------------------------------------------------===//

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ===--- convertToJSON.py ------------------------------------------------===//
#
@@ -57,8 +57,6 @@
# ]
# }
from __future__ import print_function
import json
import re
import sys

View File

@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import re
import subprocess
import sys

View File

@@ -13,7 +13,6 @@
import SwiftShims
%{
from __future__ import division
from SwiftIntTypes import all_integer_types
from SwiftFloatingPointTypes import all_floating_point_types

View File

@@ -14,7 +14,6 @@
# Utility code for later in this template
#
from __future__ import division
from SwiftIntTypes import all_integer_types, int_max_bits, should_define_truncating_bit_pattern_init
from SwiftFloatingPointTypes import getFtoIBounds

View File

@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
%{
from __future__ import division
from SwiftIntTypes import all_integer_types
word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
storagescalarCounts = [2,4,8,16,32,64]

View File

@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
%{
from __future__ import division
from SwiftIntTypes import all_integer_types
word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
storagescalarCounts = [2,4,8,16,32,64]

View File

@@ -1,11 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Renames files or directories with "module-triple-here" in their names to use
the indicated module triples instead.
"""
from __future__ import print_function
import os
import platform
import shutil

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# fake-build-for-bitcode.py - Fake build with -embed-bitcode -*- python -*-
#
# This source file is part of the Swift.org open source project
@@ -16,8 +16,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# fake-build-for-whole-module.py - Optimized fake build -*- python -*-
#
# This source file is part of the Swift.org open source project
@@ -15,8 +15,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# modify-non-primary-files.py - Fake build while modifying files -*- python -*-
#
# This source file is part of the Swift.org open source project
@@ -16,8 +16,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# touch.py - /bin/touch that writes the LLVM epoch -*- python -*-
#
# This source file is part of the Swift.org open source project

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# update-dependencies-bad.py - Fails on bad.swift -*- python -*-
#
# This source file is part of the Swift.org open source project
@@ -17,8 +17,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import shutil
import signal

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# update-dependencies.py - Fake build for dependency analysis -*- python -*-
#
# This source file is part of the Swift.org open source project
@@ -27,8 +27,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import shutil
import subprocess

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# crash.py - Sends SIGKILL to self. -*- python -*-
#
# This source file is part of the Swift.org open source project

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# crash.py - Sends SIGKILL to self. -*- python -*-
#
# This source file is part of the Swift.org open source project

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# fail.py - Just exits with an error code -*- python -*-
#
# This source file is part of the Swift.org open source project

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# clang++ - Fake Clang to test finding clang++ in the toolchain path
#
# This source file is part of the Swift.org open source project
@@ -11,6 +11,4 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
print("Sorry, I'm lazy-clang")

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# ld - Fake ld to test finding the Darwin linker in the toolchain path
#
# This source file is part of the Swift.org open source project
@@ -11,6 +11,4 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
print("Sorry, wrong number!")

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# check-filelist-abc.py - Fake build to test driver-produced -filelists.
#
# This source file is part of the Swift.org open source project
@@ -11,8 +11,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# fake-ld.py - Fake Darwin linker to test driver-produced -filelists.
#
# This source file is part of the Swift.org open source project
@@ -11,8 +11,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import sys
filelistFile = sys.argv[sys.argv.index('-filelist') + 1]

View File

@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import argparse
import io

View File

@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import os
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import subprocess
import sys

View File

@@ -1,4 +1,4 @@
#!/uar/bin/env python
#!/uar/bin/env python3
import subprocess
import sys

View File

@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3
# -*- python -*-
# RUN: %{python} %s '%swift_src_root'

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# check-is-new.py - a more-legible way to read a timestamp test than test(1)
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# check-is-old.py - a more-legible way to read a timestamp test than test(1)
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# make-old.py - /bin/touch that writes a constant "old" timestamp.
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Exercise the SwiftRemoteMirrorLegacyInterop API. This works with
# multiple versions of Swift. It builds Swift code using all versions,
@@ -7,8 +7,6 @@
#
# Invoke by passing the various Swift build directories as parameters.
from __future__ import print_function
import itertools
import os
import subprocess

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import subprocess
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# sourcekitd_path_sanitize.py - Cleans up paths from sourcekitd-test output
#
# This source file is part of the Swift.org open source project

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# coding=utf8
"""
@@ -6,8 +6,6 @@ Convert selected @objc attributes in a source file into access notes, removing
the originals in the process.
"""
from __future__ import print_function
import io
import re
import sys

View File

@@ -18,7 +18,6 @@
#
# -----------------------------------------------------------------------------
from __future__ import absolute_import
import os
import platform
import re

View File

@@ -20,7 +20,6 @@
// REQUIRES: OS=macosx
%{
from __future__ import division
word_bits = int(WORD_BITS) // 2
from SwiftIntTypes import all_integer_types
}%

View File

@@ -17,7 +17,6 @@
// RUN: %line-directive %t/NumericParsing.swift -- %target-run %t/a.out
// REQUIRES: executable_test
%{
from __future__ import division
from SwiftIntTypes import all_integer_types
word_bits = int(CMAKE_SIZEOF_VOID_P)

View File

@@ -20,7 +20,6 @@
import StdlibUnittest
%{
from __future__ import division
from SwiftIntTypes import all_integer_types
word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
storagescalarCounts = [2,4,8,16,32,64]

View File

@@ -20,7 +20,6 @@
import StdlibUnittest
%{
from __future__ import division
from SwiftIntTypes import all_integer_types
word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
storagescalarCounts = [2,4,8,16,32,64]

View File

@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import argparse
import os

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function, unicode_literals
import argparse
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# utils/PathSanitizingFileCheck -*- python -*-
#
# This source file is part of the Swift.org open source project
@@ -9,8 +9,6 @@
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import print_function
import argparse
import io
import re

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import argparse
import re

View File

@@ -15,8 +15,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import subprocess
import tempfile

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# adb_reboot.py - Reboots and cleans an Android device. -*- python -*-
#
# This source file is part of the Swift.org open source project

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# adb_push_build_products.py - Push libraries to Android device -*- python -*-
#
# This source file is part of the Swift.org open source project

View File

@@ -15,8 +15,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import argparse
import glob
import os

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# adb_test_runner.py - Calls adb_test_runner.main -*- python -*-
#
# This source file is part of the Swift.org open source project

View File

@@ -17,8 +17,6 @@
#
# ----------------------------------------------------------------------------
from __future__ import print_function
import os
import sys

View File

@@ -1,7 +1,5 @@
#!/usr/bin/env python -u
from __future__ import print_function
import os
import sys

View File

@@ -1,7 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function
import argparse
import os
import subprocess

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# utils/apply-fixit-edits.py - Apply edits from .remap files -*- python -*-
#
# This source file is part of the Swift.org open source project
@@ -9,8 +9,6 @@
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import print_function
import argparse
import collections
import json

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
@@ -22,8 +22,6 @@ StaticString, StaticString, UInt, flags : UInt32) -> () + 444
"""
from __future__ import absolute_import, print_function, unicode_literals
import argparse
import re
import sys

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import argparse

View File

@@ -1,5 +1,3 @@
from __future__ import print_function
import md5
import os
import sys

View File

@@ -1,5 +1,3 @@
from __future__ import print_function
import random
TESTRESULT_NOFAILURE = "NoFailure"

View File

@@ -1,5 +1,3 @@
from __future__ import print_function
import json
import md5
import subprocess

View File

@@ -1,5 +1,3 @@
from __future__ import print_function
import json
import random
import subprocess

View File

@@ -1,5 +1,3 @@
from __future__ import print_function
import os
import subprocess

View File

@@ -14,8 +14,6 @@ The ultimate tool for building Swift.
"""
from __future__ import absolute_import, print_function, unicode_literals
import json
import os
import platform

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# utils/build-tooling-libs - Helper tool for building the SwiftSyntax paresr
# and SwiftStaticMirror libraries -*- python -*-
#
@@ -23,8 +23,6 @@
# This utility also provides capability to gather profile data and build the parser
# library with PGO optimization enabled.
from __future__ import print_function
import copy
import multiprocessing
import os

View File

@@ -14,8 +14,6 @@ constructing parsers and more argument types. This module exposes a strict
super-set of the argparse API and is meant to be used as a drop-in replacement.
"""
from __future__ import absolute_import, unicode_literals
from argparse import (ArgumentDefaultsHelpFormatter, ArgumentError,
ArgumentTypeError, FileType, HelpFormatter,
Namespace, RawDescriptionHelpFormatter,

View File

@@ -13,8 +13,6 @@ default actions provided by the standard argparse.
"""
from __future__ import absolute_import, unicode_literals
import argparse
import copy

View File

@@ -13,9 +13,6 @@ destination actions as well as a new builder DSL for declaratively
constructing complex parsers.
"""
from __future__ import absolute_import, unicode_literals
import argparse
from contextlib import contextmanager

View File

@@ -13,8 +13,6 @@ arguments.
"""
from __future__ import absolute_import, unicode_literals
import os.path
import re
import shlex

View File

@@ -11,9 +11,6 @@
Cache related utitlity functions and decorators.
"""
from __future__ import absolute_import, unicode_literals
import functools

View File

@@ -12,9 +12,6 @@ Class utility functions and decorators.
"""
from __future__ import absolute_import, unicode_literals
__all__ = [
'generate_repr',
]

View File

@@ -6,11 +6,6 @@
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import os.path

View File

@@ -11,9 +11,6 @@
Default option value definitions.
"""
from __future__ import absolute_import, unicode_literals
import os
import platform

View File

@@ -6,9 +6,6 @@
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import multiprocessing
import os

View File

@@ -12,8 +12,6 @@ Temporary module with functionality used to migrate away from build-script-impl.
"""
from __future__ import absolute_import, unicode_literals
import itertools
import subprocess

View File

@@ -12,8 +12,6 @@ Swift preset parsing and handling functionality.
"""
from __future__ import absolute_import, unicode_literals
import configparser
import functools
import io

View File

@@ -12,8 +12,6 @@ Shell utilities wrapper module.
"""
from __future__ import absolute_import, unicode_literals
import abc
import collections
import functools

View File

@@ -12,8 +12,6 @@ Version parsing classes.
"""
from __future__ import absolute_import, unicode_literals
import functools

View File

@@ -6,9 +6,6 @@
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
from . import xcrun as _xcrun

View File

@@ -11,9 +11,6 @@
Wrapper module around the 'xcrun' command-line utility.
"""
from __future__ import absolute_import, unicode_literals
import functools
import re
import shlex

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# This source file is part of the Swift.org open source project
#
@@ -14,8 +14,6 @@ Utility script used to easily run the build_swift module unit tests.
"""
from __future__ import absolute_import, unicode_literals
import argparse
import os
import sys

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import unittest
from build_swift.argparse import (

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import unittest
from argparse import _ArgumentGroup, _MutuallyExclusiveGroup

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import os.path
import platform
import unittest

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import unittest
from build_swift import cache_utils

View File

@@ -7,9 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import
from __future__ import unicode_literals
import os.path
import unittest

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import unittest
from build_swift import defaults

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import os
import platform
import sys

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import absolute_import, unicode_literals
import platform
import unittest

View File

@@ -7,8 +7,6 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
from __future__ import unicode_literals
import configparser
import os
import unittest

Some files were not shown because too many files have changed in this diff Show More