Bug 1790816 - Reformat js/ with isort. r=linter-reviewers,ahal DONTBUILD

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D162664
This commit is contained in:
Marco Castelluccio
2022-11-24 15:22:43 +00:00
parent dbf4f554f6
commit a5255d77a3
51 changed files with 122 additions and 126 deletions

View File

@@ -39,11 +39,11 @@
from __future__ import with_statement
import errno
import re
import sys
import os
import subprocess
import re
import shlex
import subprocess
import sys
import buildconfig
import mozpack.path as mozpath

View File

@@ -42,33 +42,36 @@
"""
from __future__ import print_function
import os
import re
import io
import json
import os
import re
import sys
import tarfile
import tempfile
import yaml
from contextlib import closing
from functools import partial, total_ordering
from itertools import chain, groupby, tee
from operator import attrgetter, itemgetter
from zipfile import ZipFile
import yaml
if sys.version_info.major == 2:
from itertools import (
ifilter as filter,
ifilterfalse as filterfalse,
imap as map,
izip_longest as zip_longest,
)
from urllib2 import urlopen, Request as UrlRequest
from itertools import ifilter as filter
from itertools import ifilterfalse as filterfalse
from itertools import imap as map
from itertools import izip_longest as zip_longest
from urllib2 import Request as UrlRequest
from urllib2 import urlopen
from urlparse import urlsplit
else:
from itertools import filterfalse, zip_longest
from urllib.request import urlopen, Request as UrlRequest
from urllib.parse import urlsplit
from urllib.request import Request as UrlRequest
from urllib.request import urlopen
# From https://docs.python.org/3/library/itertools.html

View File

@@ -8,15 +8,14 @@ import argparse
import json
import logging
import multiprocessing
import re
import os
import platform
import posixpath
import re
import shlex
import shutil
import subprocess
import sys
from collections import Counter, namedtuple
from logging import info
from os import environ as env

View File

@@ -4,12 +4,12 @@
# Works with python2.6
import json
import math
import os
import sys
import math
import json
from subprocess import Popen, PIPE
from operator import itemgetter
from subprocess import PIPE, Popen
class Test:

View File

@@ -9,11 +9,11 @@
Runs the static rooting analysis
"""
from subprocess import Popen
import argparse
import os
import subprocess
import sys
from subprocess import Popen
try:
from shlex import quote

View File

@@ -8,7 +8,6 @@ from __future__ import print_function
import argparse
import re
from collections import defaultdict
parser = argparse.ArgumentParser(description="Process some integers.")

View File

@@ -13,21 +13,15 @@ import os
import sys
import textwrap
from mach.base import FailedCommandError, MachError
from mach.decorators import (
CommandArgument,
Command,
SubCommand,
)
from mach.registrar import Registrar
from mozbuild.mozconfig import MozconfigLoader
# Command files like this are listed in build/mach_initialize.py in alphabetical
# order, but we need to access commands earlier in the sorted order to grab
# their arguments. Force them to load now.
import mozbuild.artifact_commands # NOQA: F401
import mozbuild.build_commands # NOQA: F401
from mach.base import FailedCommandError, MachError
from mach.decorators import Command, CommandArgument, SubCommand
from mach.registrar import Registrar
from mozbuild.mozconfig import MozconfigLoader
# Use a decorator to copy command arguments off of the named command. Instead

View File

@@ -5,11 +5,10 @@
from __future__ import print_function
import argparse
import os
import site
import subprocess
import argparse
from glob import glob
scriptdir = os.path.abspath(os.path.dirname(__file__))

View File

@@ -3,9 +3,9 @@ import os
import re
import subprocess
import sys
from collections import defaultdict, namedtuple
from sixgill import Body
from collections import defaultdict, namedtuple
scriptdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))

View File

@@ -14,6 +14,7 @@
"""
from __future__ import print_function
import re
import sys

View File

@@ -54,8 +54,8 @@
# NOTE: If you add new phases here the current next phase kind number can be
# found at the end of js/src/gc/StatsPhasesGenerated.inc
import re
import collections
import re
class PhaseKind:

View File

@@ -4,11 +4,12 @@
# flake8: noqa: F821
import gdb
import re
import sys
import traceback
import gdb
# testlibdir is set on the GDB command line, via --eval-command python testlibdir=...
sys.path[0:0] = [testlibdir]

View File

@@ -6,7 +6,6 @@
import gdb
import mozilla.prettyprinters
from mozilla.prettyprinters import pretty_printer
# Forget any printers from previous loads of this module.

View File

@@ -11,11 +11,12 @@ This python script should be sourced within GDB after loading the python scripts
provided with SpiderMonkey.
"""
import gdb
import os
import subprocess
import tempfile
import time
import gdb
import mozilla.prettyprinters
from mozilla.prettyprinters import pretty_printer

View File

@@ -5,11 +5,12 @@
# Pretty-printers for SpiderMonkey JSObjects.
import re
import gdb
import mozilla.prettyprinters as prettyprinters
from mozilla.CellHeader import get_header_ptr
from mozilla.jsval import JSValue
from mozilla.prettyprinters import ptr_pretty_printer, ref_pretty_printer
from mozilla.CellHeader import get_header_ptr
prettyprinters.clear_module_printers(__name__)

View File

@@ -6,8 +6,8 @@
import gdb
import mozilla.prettyprinters
from mozilla.prettyprinters import ptr_pretty_printer
from mozilla.CellHeader import get_header_length_and_flags
from mozilla.prettyprinters import ptr_pretty_printer
try:
chr(10000) # UPPER RIGHT PENCIL

View File

@@ -5,8 +5,8 @@
# Pretty-printer for SpiderMonkey symbols.
import mozilla.prettyprinters
from mozilla.prettyprinters import ptr_pretty_printer
from mozilla.CellHeader import get_header_ptr
from mozilla.prettyprinters import ptr_pretty_printer
# Forget any printers from previous loads of this module.
mozilla.prettyprinters.clear_module_printers(__name__)

View File

@@ -6,7 +6,6 @@
import mozilla.prettyprinters
import mozilla.Root
from mozilla.prettyprinters import pretty_printer
# Forget any printers from previous loads of this module.

View File

@@ -8,21 +8,21 @@ print("Loading JavaScript value pretty-printers; see js/src/gdb/README.")
print("If they cause trouble, type: disable pretty-printer .* SpiderMonkey")
import gdb.printing
import mozilla.prettyprinters
import mozilla.ExecutableAllocator
# Import the pretty-printer modules. As a side effect, loading these
# modules registers their printers with mozilla.prettyprinters.
import mozilla.GCCellPtr
import mozilla.ExecutableAllocator
import mozilla.Interpreter
import mozilla.IonGraph
import mozilla.JSObject
import mozilla.jsop
import mozilla.JSString
import mozilla.JSSymbol
import mozilla.Root
import mozilla.PropertyKey
import mozilla.jsop
import mozilla.jsval
import mozilla.prettyprinters
import mozilla.PropertyKey
import mozilla.Root
import mozilla.unwind
# The user may have personal pretty-printers. Get those, too, if they exist.

View File

@@ -10,9 +10,10 @@
# => 0x240e954ac13a: pushq (%rbx)
# (rr) jitsrc 0x240e954ac13a
import gdb
import re
import gdb
# (base_name, hops, func_name, source_var, dest_var) tuples, such that :
# - `base_name`: a regex matching the name of the function that implements
# the actual write

View File

@@ -4,9 +4,10 @@
# Pretty-printers for SpiderMonkey's JS::Value.
import struct
import gdb
import gdb.types
import struct
import mozilla.prettyprinters
from mozilla.prettyprinters import pretty_printer

View File

@@ -4,9 +4,10 @@
# mozilla/prettyprinters.py --- infrastructure for SpiderMonkey's auto-loaded pretty-printers.
import gdb
import re
import gdb
# Decorators for declaring pretty-printers.
#
# In each case, the decoratee should be a SpiderMonkey-style pretty-printer

View File

@@ -4,12 +4,13 @@
# mozilla/unwind.py --- unwinder and frame filter for SpiderMonkey
import platform
import gdb
import gdb.types
from gdb.FrameDecorator import FrameDecorator
from mozilla.JSObject import get_function_name, get_function_script
from mozilla.prettyprinters import TypeCache
import platform
# For ease of use in Python 2, we use "long" instead of "int"
# everywhere.

View File

@@ -4,8 +4,8 @@
# Text progress bar library, like curl or scp.
import sys
import datetime
import sys
import time

View File

@@ -8,7 +8,7 @@ import fcntl
import os
import select
import time
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
class TaskPool(object):

View File

@@ -27,8 +27,8 @@
import os
import re
import sys
import subprocess
import sys
from pathlib import Path

View File

@@ -14,7 +14,6 @@ import subprocess
import sys
import traceback
read_input = input
if sys.version_info.major == 2:
read_input = raw_input
@@ -31,14 +30,14 @@ def add_tests_dir_to_path():
add_tests_dir_to_path()
from lib import jittests
from lib.tempfile import TemporaryDirectory
from lib.tests import (
get_jitflags,
valid_jitflags,
change_env,
get_cpu_count,
get_environment_overlay,
change_env,
get_jitflags,
valid_jitflags,
)
from lib.tempfile import TemporaryDirectory
def which(name):

View File

@@ -4,10 +4,11 @@
# This script generates jit/CacheIROpsGenerated.h from CacheIROps.yaml
import buildconfig
import yaml
import six
from collections import OrderedDict
import buildconfig
import six
import yaml
from mozbuild.preprocessor import Preprocessor
HEADER_TEMPLATE = """\

View File

@@ -5,10 +5,11 @@
# This script generates jit/LIROpsGenerated.h (list of LIR instructions)
# from LIROps.yaml.
import buildconfig
import yaml
import six
from collections import OrderedDict
import buildconfig
import six
import yaml
from mozbuild.preprocessor import Preprocessor
HEADER_TEMPLATE = """\

View File

@@ -5,10 +5,11 @@
# This script generates jit/MIROpsGenerated.h (list of MIR instructions)
# from MIROps.yaml, as well as MIR op definitions.
import buildconfig
import yaml
import six
from collections import OrderedDict
import buildconfig
import six
import yaml
from mozbuild.preprocessor import Preprocessor
HEADER_TEMPLATE = """\

View File

@@ -7,12 +7,12 @@
# This script will be installed into $objdir/dist/bin. Add $objdir to gdb's
# source search path and load in the Gecko+JS init file.
import gdb
import os
import re
from os.path import abspath, dirname
import gdb
devel_objdir = abspath(os.path.join(dirname(__file__), "..", ".."))
m = re.search(r"[\w ]+: (.*)", gdb.execute("show dir", False, True))
if m and devel_objdir not in m.group(1).split(":"):

View File

@@ -13,31 +13,30 @@ from __future__ import print_function
import math
import os
import platform
import posixpath
import re
import shlex
import sys
import tempfile
import platform
from os.path import abspath, dirname, isfile, realpath
from contextlib import contextmanager
from copy import copy
from datetime import datetime
from itertools import chain
from subprocess import list2cmdline, call
from os.path import abspath, dirname, isfile, realpath
from subprocess import call, list2cmdline
from lib.adaptor import xdr_annotate
from lib.progressbar import ProgressBar
from lib.results import ResultsSink, TestOutput
from lib.tempfile import TemporaryDirectory
from lib.tests import (
RefTestCase,
get_jitflags,
change_env,
get_cpu_count,
get_environment_overlay,
change_env,
get_jitflags,
)
from lib.results import ResultsSink, TestOutput
from lib.progressbar import ProgressBar
from lib.adaptor import xdr_annotate
from lib.tempfile import TemporaryDirectory
if sys.platform.startswith("linux") or sys.platform.startswith("darwin"):
from lib.tasks_unix import run_all_tests
@@ -539,7 +538,7 @@ def load_wpt_tests(xul_tester, requested_paths, excluded_paths, update_manifest=
sys.path[0:0] = abs_sys_paths
import manifestupdate
from wptrunner import products, testloader, wptcommandline, wpttest, wptlogging
from wptrunner import products, testloader, wptcommandline, wptlogging, wpttest
manifest_root = tempfile.gettempdir()
(maybe_dist, maybe_bin) = os.path.split(os.path.dirname(xul_tester.js_bin))
@@ -799,7 +798,7 @@ def main():
if options.remote:
results = ResultsSink("jstests", options, test_count)
try:
from lib.remote import init_remote_dir, init_device
from lib.remote import init_device, init_remote_dir
device = init_device(options)
tempdir = posixpath.join(options.remote_test_root, "tmp")

View File

@@ -7,6 +7,7 @@
# jit_test.py -- Python harness for JavaScript trace tests.
from __future__ import print_function
import os
import re
import sys
@@ -18,7 +19,7 @@ if sys.platform.startswith("linux") or sys.platform.startswith("darwin"):
else:
from .tasks_win import run_all_tests
from .progressbar import ProgressBar, NullProgressBar
from .progressbar import NullProgressBar, ProgressBar
from .results import escape_cmdline
from .structuredlog import TestLogger
from .tempfile import TemporaryDirectory
@@ -799,9 +800,10 @@ def run_tests_local(tests, num_tests, prefix, options, slog):
def run_tests_remote(tests, num_tests, prefix, options, slog):
# Setup device with everything needed to run our tests.
from .tasks_adb_remote import get_remote_results
from mozdevice import ADBError, ADBTimeoutError
from .tasks_adb_remote import get_remote_results
# Run all tests.
pb = create_progressbar(num_tests, options)
try:

View File

@@ -8,9 +8,10 @@ import io
import os
import posixpath
import re
import six
import sys
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
import six
from .remote import init_device
from .tests import RefTestCase

View File

@@ -2,7 +2,6 @@
import math
import sys
from datetime import datetime, timedelta
if sys.platform.startswith("win"):

View File

@@ -5,7 +5,6 @@ from __future__ import print_function
import json
import os
from time import time

View File

@@ -1,19 +1,19 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. */
from __future__ import print_function, unicode_literals, division
from __future__ import division, print_function, unicode_literals
import os
import posixpath
import sys
import tempfile
from datetime import timedelta
from mozdevice import ADBDevice, ADBError, ADBTimeoutError, ADBProcessError
from .results import TestOutput, escape_cmdline
from mozdevice import ADBDevice, ADBError, ADBProcessError, ADBTimeoutError
from .adaptor import xdr_annotate
from .remote import init_device
from .results import TestOutput, escape_cmdline
TESTS_LIB_DIR = os.path.dirname(os.path.abspath(__file__))
JS_DIR = os.path.dirname(os.path.dirname(TESTS_LIB_DIR))

View File

@@ -7,16 +7,11 @@ import os
import select
import signal
import sys
from datetime import datetime, timedelta
from .progressbar import ProgressBar
from .results import (
NullTestOutput,
TestOutput,
escape_cmdline,
)
from .adaptor import xdr_annotate
from .progressbar import ProgressBar
from .results import NullTestOutput, TestOutput, escape_cmdline
class Task(object):

View File

@@ -1,18 +1,18 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. */
from __future__ import print_function, unicode_literals, division
from __future__ import division, print_function, unicode_literals
import subprocess
import sys
from datetime import datetime, timedelta
from threading import Thread
from six.moves.queue import Queue, Empty
from six.moves.queue import Empty, Queue
from .adaptor import xdr_annotate
from .progressbar import ProgressBar
from .results import NullTestOutput, TestOutput, escape_cmdline
from .adaptor import xdr_annotate
class EndMarker:

View File

@@ -7,8 +7,8 @@ try:
# Python 3.2
from tempfile import TemporaryDirectory
except ImportError:
import tempfile
import shutil
import tempfile
from contextlib import contextmanager
@contextmanager

View File

@@ -9,7 +9,7 @@ GetConsoleScreenBufferInfo.
$Id: color_console.py 534 2009-05-10 04:00:59Z andre $
"""
from ctypes import windll, Structure, c_short, c_ushort, byref
from ctypes import Structure, byref, c_short, c_ushort, windll
SHORT = c_short
WORD = c_ushort

View File

@@ -8,6 +8,7 @@
"""
from __future__ import print_function
import re
import sys

View File

@@ -23,12 +23,12 @@ Arguments:
from __future__ import print_function
import json
import math
import optparse
import os
import subprocess as subp
import sys
import json
from string import Template
try:

View File

@@ -1,11 +1,11 @@
#!/usr/bin/env python
# Adapted from https://github.com/tc39/test262/blob/main/tools/generation/test/run.py
import contextlib
import os
import shutil
import subprocess
import contextlib
import tempfile
import os
import unittest
testDir = os.path.dirname(os.path.relpath(__file__))

View File

@@ -11,6 +11,7 @@ import os
import re
import shutil
import sys
import yaml
# Skip all common files used to support tests for jstests

View File

@@ -10,10 +10,9 @@ from __future__ import print_function
import contextlib
import io
import os
import tempfile
import shutil
import sys
import tempfile
from functools import partial
from itertools import chain
from operator import itemgetter
@@ -565,7 +564,6 @@ def fetch_local_changes(inDir, outDir, srcDir, strictTests):
import subprocess
# TODO: fail if it's in the default branch? or require a branch name?
# Checks for unstaged or non committed files. A clean branch provides a clean status.
status = subprocess.check_output(
("git -C %s status --porcelain" % srcDir).split(" ")

View File

@@ -23,8 +23,8 @@ from __future__ import print_function, unicode_literals
import csv
import io
import re
import os
import re
import sys
from contextlib import closing
from functools import partial
@@ -33,7 +33,10 @@ from operator import is_not, itemgetter
from zipfile import ZipFile
if sys.version_info.major == 2:
from itertools import ifilter as filter, imap as map, izip_longest as zip_longest
from itertools import ifilter as filter
from itertools import imap as map
from itertools import izip_longest as zip_longest
from urllib2 import urlopen
range = xrange

View File

@@ -14,18 +14,17 @@
https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
"""
import sys
import os
import sys
# Allow this script to be run from anywhere.
this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, this_dir)
import jsopcode
from xml.sax.saxutils import escape
import jsopcode
try:
import markdown

View File

@@ -1,7 +1,8 @@
import buildconfig
import yaml
import six
from collections import OrderedDict
import buildconfig
import six
import yaml
from mozbuild.preprocessor import Preprocessor
HEADER_TEMPLATE = """\

View File

@@ -1,11 +1,10 @@
#!/usr/bin/env python
from __future__ import absolute_import, print_function
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import io
import os
import struct

View File

@@ -6,10 +6,7 @@ import argparse
import sys
from pathlib import Path
from mach.decorators import (
Command,
CommandArgument,
)
from mach.decorators import Command, CommandArgument
@Command("xpcshell", category="misc", description="Run the xpcshell binary")