diff --git a/xpcom/base/ErrorList.py b/xpcom/base/ErrorList.py index 7d93a36edc06..2fd3b8b4b938 100755 --- a/xpcom/base/ErrorList.py +++ b/xpcom/base/ErrorList.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import absolute_import + from collections import OrderedDict @@ -1379,9 +1380,10 @@ use super::nsresult; def gen_jinja(output, input_filename): # This is used to generate Java code for error lists, and can be expanded to # other required contexts in the future if desired. - from jinja2 import Environment, FileSystemLoader, StrictUndefined import os + from jinja2 import Environment, FileSystemLoader, StrictUndefined + # FileSystemLoader requires the path to the directory containing templates, # not the file name of the template itself. (path, leaf) = os.path.split(input_filename) diff --git a/xpcom/components/gen_static_components.py b/xpcom/components/gen_static_components.py index ea05f7ae524f..1ee534b53ba3 100644 --- a/xpcom/components/gen_static_components.py +++ b/xpcom/components/gen_static_components.py @@ -3,13 +3,11 @@ import os import re import struct from collections import defaultdict - from uuid import UUID +import buildconfig from mozbuild.util import FileAvoidWrite from perfecthash import PerfectHash -import buildconfig - NO_CONTRACT_ID = 0xFFFFFFFF diff --git a/xpcom/components/test/test_gen_static_components.py b/xpcom/components/test/test_gen_static_components.py index 9a77a2a3ca2b..6224342197dc 100644 --- a/xpcom/components/test/test_gen_static_components.py +++ b/xpcom/components/test/test_gen_static_components.py @@ -2,11 +2,12 @@ # 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/. -import mozunit import os import sys import unittest +import mozunit + sys.path.append(os.path.join(os.path.dirname(__file__), "..")) import gen_static_components from gen_static_components import BackgroundTasksSelector diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index adfb804ed271..8ff3dcb090e7 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -4,11 +4,16 @@ # flake8: noqa -from Atom import Atom, InheritingAnonBoxAtom, NonInheritingAnonBoxAtom -from Atom import PseudoElementAtom -from HTMLAtoms import HTML_PARSER_ATOMS import sys +from Atom import ( + Atom, + InheritingAnonBoxAtom, + NonInheritingAnonBoxAtom, + PseudoElementAtom, +) +from HTMLAtoms import HTML_PARSER_ATOMS + # Static atom definitions, used to generate nsGkAtomList.h. # # Each atom is defined by a call to Atom, PseudoElementAtom, diff --git a/xpcom/ds/test/test_dafsa.py b/xpcom/ds/test/test_dafsa.py index fb16aec2b326..9becdd6c06c7 100644 --- a/xpcom/ds/test/test_dafsa.py +++ b/xpcom/ds/test/test_dafsa.py @@ -2,10 +2,11 @@ # 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 io import StringIO -from incremental_dafsa import Dafsa, Node -import mozunit import unittest +from io import StringIO + +import mozunit +from incremental_dafsa import Dafsa, Node def _node_to_string(node: Node, prefix, buffer, cache): diff --git a/xpcom/ds/tools/incremental_dafsa.py b/xpcom/ds/tools/incremental_dafsa.py index 3c76109efe28..1157c268508f 100644 --- a/xpcom/ds/tools/incremental_dafsa.py +++ b/xpcom/ds/tools/incremental_dafsa.py @@ -10,7 +10,7 @@ functions for converting to a compatible structure. This legacy format is define in make_dafsa.py. """ -from typing import List, Dict, Optional, Callable +from typing import Callable, Dict, List, Optional class Node: diff --git a/xpcom/ds/tools/make_dafsa.py b/xpcom/ds/tools/make_dafsa.py index 7b1e7cb9f4ef..a9cedf78a8c0 100644 --- a/xpcom/ds/tools/make_dafsa.py +++ b/xpcom/ds/tools/make_dafsa.py @@ -170,8 +170,8 @@ The bytes in the generated array has the following meaning: 9: 0x62 label character 0x62 -> match "b" 10: 0x82 0x82 & 0x0F -> return 2 """ -import sys import struct +import sys from incremental_dafsa import Dafsa, Node diff --git a/xpcom/ds/tools/perfecthash.py b/xpcom/ds/tools/perfecthash.py index c4f890624834..6474856f1f55 100644 --- a/xpcom/ds/tools/perfecthash.py +++ b/xpcom/ds/tools/perfecthash.py @@ -21,10 +21,11 @@ maintainable, rather than being as optimized as possible, due to the relatively small dataset it was designed for. In the future we may want to optimize further. """ -from collections import namedtuple -from mozbuild.util import ensure_bytes import textwrap +from collections import namedtuple + import six +from mozbuild.util import ensure_bytes # Iteration over bytestrings works differently in Python 2 and 3; this function diff --git a/xpcom/geckoprocesstypes_generator/setup.py b/xpcom/geckoprocesstypes_generator/setup.py index 148f82f32061..9fd8dff82d7b 100644 --- a/xpcom/geckoprocesstypes_generator/setup.py +++ b/xpcom/geckoprocesstypes_generator/setup.py @@ -2,8 +2,7 @@ # 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 setuptools import setup, find_packages - +from setuptools import find_packages, setup setup( name="geckoprocesstypes", diff --git a/xpcom/idl-parser/setup.py b/xpcom/idl-parser/setup.py index 31cc5063b750..af6b417cb7a3 100644 --- a/xpcom/idl-parser/setup.py +++ b/xpcom/idl-parser/setup.py @@ -2,8 +2,7 @@ # 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 setuptools import setup, find_packages - +from setuptools import find_packages, setup setup( name="xpidl", diff --git a/xpcom/idl-parser/xpidl/header.py b/xpcom/idl-parser/xpidl/header.py index a63ded29e14a..c8b51f60f700 100644 --- a/xpcom/idl-parser/xpidl/header.py +++ b/xpcom/idl-parser/xpidl/header.py @@ -9,10 +9,11 @@ from __future__ import absolute_import +import itertools import os.path import re + from xpidl import xpidl -import itertools printdoccomments = False diff --git a/xpcom/idl-parser/xpidl/jsonxpt.py b/xpcom/idl-parser/xpidl/jsonxpt.py index 7b9e9143e268..4b63d8ffb93e 100644 --- a/xpcom/idl-parser/xpidl/jsonxpt.py +++ b/xpcom/idl-parser/xpidl/jsonxpt.py @@ -9,9 +9,10 @@ from __future__ import absolute_import -from xpidl import xpidl -import json import itertools +import json + +from xpidl import xpidl # A map of xpidl.py types to xpt enum variants TypeMap = { diff --git a/xpcom/idl-parser/xpidl/runtests.py b/xpcom/idl-parser/xpidl/runtests.py index ec4ce97c5e6f..aa610cfdffd1 100755 --- a/xpcom/idl-parser/xpidl/runtests.py +++ b/xpcom/idl-parser/xpidl/runtests.py @@ -14,10 +14,10 @@ import sys # which conflicts with the xpidl submodule in the imports further below. sys.path.pop(0) -import mozunit import unittest -from xpidl import xpidl -from xpidl import header + +import mozunit +from xpidl import header, xpidl class TestParser(unittest.TestCase): diff --git a/xpcom/idl-parser/xpidl/rust.py b/xpcom/idl-parser/xpidl/rust.py index e37d33abb53d..1e35bf018715 100644 --- a/xpcom/idl-parser/xpidl/rust.py +++ b/xpcom/idl-parser/xpidl/rust.py @@ -38,6 +38,7 @@ from __future__ import absolute_import import os.path import re + from xpidl import xpidl diff --git a/xpcom/idl-parser/xpidl/rust_macros.py b/xpcom/idl-parser/xpidl/rust_macros.py index 15e4467f479f..00ec506d7b0e 100644 --- a/xpcom/idl-parser/xpidl/rust_macros.py +++ b/xpcom/idl-parser/xpidl/rust_macros.py @@ -8,9 +8,7 @@ from __future__ import absolute_import -from xpidl import rust -from xpidl import xpidl - +from xpidl import rust, xpidl derive_method_tmpl = """\ Method { diff --git a/xpcom/idl-parser/xpidl/xpidl.py b/xpcom/idl-parser/xpidl/xpidl.py index 3cd58f5326ec..0cd3e6da47f3 100755 --- a/xpcom/idl-parser/xpidl/xpidl.py +++ b/xpcom/idl-parser/xpidl/xpidl.py @@ -7,18 +7,17 @@ """A parser for cross-platform IDL (XPIDL) files.""" -from __future__ import absolute_import -from __future__ import print_function +from __future__ import absolute_import, print_function -import sys import os.path import re -from ply import lex -from ply import yacc -import six +import sys import textwrap from collections import namedtuple +import six +from ply import lex, yacc + """A type conforms to the following pattern: def nativeType(self, calltype): diff --git a/xpcom/reflect/xptcall/md/win32/preprocess.py b/xpcom/reflect/xptcall/md/win32/preprocess.py index bbf1affd00ae..a2f3232c344e 100644 --- a/xpcom/reflect/xptcall/md/win32/preprocess.py +++ b/xpcom/reflect/xptcall/md/win32/preprocess.py @@ -5,10 +5,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import errno -import sys import os import shlex import subprocess +import sys import tempfile import buildconfig diff --git a/xpcom/reflect/xptinfo/xptcodegen.py b/xpcom/reflect/xptinfo/xptcodegen.py index db34fb80a348..34131f6678ef 100644 --- a/xpcom/reflect/xptinfo/xptcodegen.py +++ b/xpcom/reflect/xptinfo/xptcodegen.py @@ -6,9 +6,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import json -from perfecthash import PerfectHash from collections import OrderedDict + import buildconfig +from perfecthash import PerfectHash # Pick a nice power-of-two size for our intermediate PHF tables. PHFSIZE = 512 @@ -628,8 +629,8 @@ def link_and_write(files, outfile, outheader): def main(): - from argparse import ArgumentParser import sys + from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument("outfile", help="Output C++ file to generate")