Skip to content

Instantly share code, notes, and snippets.

@timothycrosley
Created October 2, 2020 06:12
Show Gist options
  • Save timothycrosley/009e2803d03513186dd414349e52b918 to your computer and use it in GitHub Desktop.
Save timothycrosley/009e2803d03513186dd414349e52b918 to your computer and use it in GitHub Desktop.
diff produced from running isort on yapf project
diff --git a/setup.py b/setup.py
index 21e9470..ecf9b6a 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,8 @@ import codecs
import sys
import unittest
-from setuptools import setup, Command
+from setuptools import Command
+from setuptools import setup
import yapf
diff --git a/yapf/__init__.py b/yapf/__init__.py
index 3aca8bd..ec973da 100644
--- a/yapf/__init__.py
+++ b/yapf/__init__.py
@@ -28,12 +28,11 @@ If no filenames are specified, YAPF reads the code from stdin.
from __future__ import print_function
import argparse
+from lib2to3.pgen2 import tokenize
import logging
import os
import sys
-from lib2to3.pgen2 import tokenize
-
from yapf.yapflib import errors
from yapf.yapflib import file_resources
from yapf.yapflib import py3compat
@@ -188,8 +187,8 @@ def FormatFiles(filenames,
"""
changed = False
if parallel:
- import multiprocessing # pylint: disable=g-import-not-at-top
import concurrent.futures # pylint: disable=g-import-not-at-top
+ import multiprocessing # pylint: disable=g-import-not-at-top
workers = min(multiprocessing.cpu_count(), len(filenames))
with concurrent.futures.ProcessPoolExecutor(workers) as executor:
future_formats = [
diff --git a/yapf/yapflib/file_resources.py b/yapf/yapflib/file_resources.py
index 50b4687..31d5bf6 100644
--- a/yapf/yapflib/file_resources.py
+++ b/yapf/yapflib/file_resources.py
@@ -18,11 +18,10 @@ querying.
"""
import fnmatch
+from lib2to3.pgen2 import tokenize
import os
import re
-from lib2to3.pgen2 import tokenize
-
from yapf.yapflib import errors
from yapf.yapflib import py3compat
from yapf.yapflib import style
diff --git a/yapf/yapflib/format_token.py b/yapf/yapflib/format_token.py
index 0ed983f..b2c3ce9 100644
--- a/yapf/yapflib/format_token.py
+++ b/yapf/yapflib/format_token.py
@@ -17,9 +17,8 @@ This is a thin wrapper around a pytree.Leaf node.
"""
import keyword
-import re
-
from lib2to3.pgen2 import token
+import re
from yapf.yapflib import py3compat
from yapf.yapflib import pytree_utils
diff --git a/yapf/yapflib/pytree_utils.py b/yapf/yapflib/pytree_utils.py
index 75d4ca2..bb3d5e7 100644
--- a/yapf/yapflib/pytree_utils.py
+++ b/yapf/yapflib/pytree_utils.py
@@ -25,7 +25,6 @@ the lib2to3 library.
"""
import ast
-
from lib2to3 import pygram
from lib2to3 import pytree
from lib2to3.pgen2 import driver
diff --git a/yapf/yapflib/pytree_visitor.py b/yapf/yapflib/pytree_visitor.py
index 49da056..463a618 100644
--- a/yapf/yapflib/pytree_visitor.py
+++ b/yapf/yapflib/pytree_visitor.py
@@ -24,9 +24,8 @@ a pytree into a stream.
DumpPyTree(): a convenience function to dump a pytree.
"""
-import sys
-
from lib2to3 import pytree
+import sys
from yapf.yapflib import pytree_utils
diff --git a/yapf/yapflib/reformatter.py b/yapf/yapflib/reformatter.py
index bfc7121..6a47789 100644
--- a/yapf/yapflib/reformatter.py
+++ b/yapf/yapflib/reformatter.py
@@ -21,12 +21,12 @@ as a string.
"""
from __future__ import unicode_literals
+
import collections
import heapq
-import re
-
from lib2to3 import pytree
from lib2to3.pgen2 import token
+import re
from yapf.yapflib import format_decision_state
from yapf.yapflib import format_token
diff --git a/yapf/yapflib/split_penalty.py b/yapf/yapflib/split_penalty.py
index d4c3dc4..b3cdeec 100644
--- a/yapf/yapflib/split_penalty.py
+++ b/yapf/yapflib/split_penalty.py
@@ -13,9 +13,8 @@
# limitations under the License.
"""Computation of split penalties before/between tokens."""
-import re
-
from lib2to3 import pytree
+import re
from yapf.yapflib import format_token
from yapf.yapflib import py3compat
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/unwrapped_line.py
index 38501c0..128fa7b 100644
--- a/yapf/yapflib/unwrapped_line.py
+++ b/yapf/yapflib/unwrapped_line.py
@@ -19,14 +19,14 @@ single line if there were no line length restrictions. It's then used by the
parser to perform the wrapping required to comply with the style guide.
"""
+from lib2to3.fixer_util import syms as python_symbols
+
from yapf.yapflib import format_token
from yapf.yapflib import py3compat
from yapf.yapflib import pytree_utils
from yapf.yapflib import split_penalty
from yapf.yapflib import style
-from lib2to3.fixer_util import syms as python_symbols
-
class UnwrappedLine(object):
"""Represents a single unwrapped line in the output.
diff --git a/yapf/yapflib/yapf_api.py b/yapf/yapflib/yapf_api.py
index dde1df9..6f0c377 100644
--- a/yapf/yapflib/yapf_api.py
+++ b/yapf/yapflib/yapf_api.py
@@ -33,11 +33,10 @@ These APIs have some common arguments:
"""
import difflib
+from lib2to3.pgen2 import parse
import re
import sys
-from lib2to3.pgen2 import parse
-
from yapf.yapflib import blank_line_calculator
from yapf.yapflib import comment_splicer
from yapf.yapflib import continuation_splicer
diff --git a/yapftests/blank_line_calculator_test.py b/yapftests/blank_line_calculator_test.py
index 1ec0a5e..db11e2c 100644
--- a/yapftests/blank_line_calculator_test.py
+++ b/yapftests/blank_line_calculator_test.py
@@ -19,7 +19,6 @@ import unittest
from yapf.yapflib import reformatter
from yapf.yapflib import style
from yapf.yapflib import yapf_api
-
from yapftests import yapf_test_helper
diff --git a/yapftests/file_resources_test.py b/yapftests/file_resources_test.py
index c91d93c..3c2b7e4 100644
--- a/yapftests/file_resources_test.py
+++ b/yapftests/file_resources_test.py
@@ -23,7 +23,6 @@ import unittest
from yapf.yapflib import errors
from yapf.yapflib import file_resources
from yapf.yapflib import py3compat
-
from yapftests import utils
diff --git a/yapftests/format_decision_state_test.py b/yapftests/format_decision_state_test.py
index 39e7e8e..a2f2bed 100644
--- a/yapftests/format_decision_state_test.py
+++ b/yapftests/format_decision_state_test.py
@@ -20,7 +20,6 @@ from yapf.yapflib import format_decision_state
from yapf.yapflib import pytree_utils
from yapf.yapflib import style
from yapf.yapflib import unwrapped_line
-
from yapftests import yapf_test_helper
diff --git a/yapftests/format_token_test.py b/yapftests/format_token_test.py
index b4c7151..8b2618a 100644
--- a/yapftests/format_token_test.py
+++ b/yapftests/format_token_test.py
@@ -13,10 +13,9 @@
# limitations under the License.
"""Tests for yapf.format_token."""
-import unittest
-
from lib2to3 import pytree
from lib2to3.pgen2 import token
+import unittest
from yapf.yapflib import format_token
diff --git a/yapftests/line_joiner_test.py b/yapftests/line_joiner_test.py
index 6501bc8..d03aef2 100644
--- a/yapftests/line_joiner_test.py
+++ b/yapftests/line_joiner_test.py
@@ -18,7 +18,6 @@ import unittest
from yapf.yapflib import line_joiner
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
diff --git a/yapftests/main_test.py b/yapftests/main_test.py
index 94daaaa..746b971 100644
--- a/yapftests/main_test.py
+++ b/yapftests/main_test.py
@@ -17,8 +17,8 @@
from contextlib import contextmanager
import sys
import unittest
-import yapf
+import yapf
from yapf.yapflib import py3compat
diff --git a/yapftests/pytree_unwrapper_test.py b/yapftests/pytree_unwrapper_test.py
index f95f366..8448580 100644
--- a/yapftests/pytree_unwrapper_test.py
+++ b/yapftests/pytree_unwrapper_test.py
@@ -17,7 +17,6 @@ import textwrap
import unittest
from yapf.yapflib import pytree_utils
-
from yapftests import yapf_test_helper
diff --git a/yapftests/pytree_utils_test.py b/yapftests/pytree_utils_test.py
index 3b9fde7..bf90c48 100644
--- a/yapftests/pytree_utils_test.py
+++ b/yapftests/pytree_utils_test.py
@@ -13,11 +13,10 @@
# limitations under the License.
"""Tests for yapf.pytree_utils."""
-import unittest
-
from lib2to3 import pygram
from lib2to3 import pytree
from lib2to3.pgen2 import token
+import unittest
from yapf.yapflib import pytree_utils
diff --git a/yapftests/reformatter_basic_test.py b/yapftests/reformatter_basic_test.py
index 3e50b6a..fbb4cbe 100644
--- a/yapftests/reformatter_basic_test.py
+++ b/yapftests/reformatter_basic_test.py
@@ -19,7 +19,6 @@ import unittest
from yapf.yapflib import py3compat
from yapf.yapflib import reformatter
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py
index 653e885..74aece9 100644
--- a/yapftests/reformatter_buganizer_test.py
+++ b/yapftests/reformatter_buganizer_test.py
@@ -18,7 +18,6 @@ import unittest
from yapf.yapflib import reformatter
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
diff --git a/yapftests/reformatter_facebook_test.py b/yapftests/reformatter_facebook_test.py
index 289aa85..e8e9757 100644
--- a/yapftests/reformatter_facebook_test.py
+++ b/yapftests/reformatter_facebook_test.py
@@ -18,7 +18,6 @@ import unittest
from yapf.yapflib import reformatter
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
diff --git a/yapftests/reformatter_pep8_test.py b/yapftests/reformatter_pep8_test.py
index bdd074a..bf3bded 100644
--- a/yapftests/reformatter_pep8_test.py
+++ b/yapftests/reformatter_pep8_test.py
@@ -19,7 +19,6 @@ import unittest
from yapf.yapflib import py3compat
from yapf.yapflib import reformatter
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
diff --git a/yapftests/reformatter_python3_test.py b/yapftests/reformatter_python3_test.py
index d06e406..ff37dd9 100644
--- a/yapftests/reformatter_python3_test.py
+++ b/yapftests/reformatter_python3_test.py
@@ -20,7 +20,6 @@ import unittest
from yapf.yapflib import py3compat
from yapf.yapflib import reformatter
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
diff --git a/yapftests/reformatter_style_config_test.py b/yapftests/reformatter_style_config_test.py
index d77c197..1cd4cf1 100644
--- a/yapftests/reformatter_style_config_test.py
+++ b/yapftests/reformatter_style_config_test.py
@@ -18,7 +18,6 @@ import unittest
from yapf.yapflib import reformatter
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
diff --git a/yapftests/reformatter_verify_test.py b/yapftests/reformatter_verify_test.py
index 1b3d5b0..08ec8b2 100644
--- a/yapftests/reformatter_verify_test.py
+++ b/yapftests/reformatter_verify_test.py
@@ -20,7 +20,6 @@ from yapf.yapflib import py3compat
from yapf.yapflib import reformatter
from yapf.yapflib import style
from yapf.yapflib import verifier
-
from yapftests import yapf_test_helper
diff --git a/yapftests/split_penalty_test.py b/yapftests/split_penalty_test.py
index 4d55129..995221c 100644
--- a/yapftests/split_penalty_test.py
+++ b/yapftests/split_penalty_test.py
@@ -13,17 +13,15 @@
# limitations under the License.
"""Tests for yapf.split_penalty."""
+from lib2to3 import pytree
import sys
import textwrap
import unittest
-from lib2to3 import pytree
-
from yapf.yapflib import pytree_utils
from yapf.yapflib import pytree_visitor
from yapf.yapflib import split_penalty
from yapf.yapflib import style
-
from yapftests import yapf_test_helper
UNBREAKABLE = split_penalty.UNBREAKABLE
diff --git a/yapftests/style_test.py b/yapftests/style_test.py
index a9c478d..b74b419 100644
--- a/yapftests/style_test.py
+++ b/yapftests/style_test.py
@@ -20,7 +20,6 @@ import textwrap
import unittest
from yapf.yapflib import style
-
from yapftests import utils
diff --git a/yapftests/subtype_assigner_test.py b/yapftests/subtype_assigner_test.py
index b42b8cf..82c8dd7 100644
--- a/yapftests/subtype_assigner_test.py
+++ b/yapftests/subtype_assigner_test.py
@@ -18,7 +18,6 @@ import unittest
from yapf.yapflib import format_token
from yapf.yapflib import pytree_utils
-
from yapftests import yapf_test_helper
diff --git a/yapftests/unwrapped_line_test.py b/yapftests/unwrapped_line_test.py
index 90be1a1..00e2d89 100644
--- a/yapftests/unwrapped_line_test.py
+++ b/yapftests/unwrapped_line_test.py
@@ -13,16 +13,14 @@
# limitations under the License.
"""Tests for yapf.unwrapped_line."""
-import textwrap
-import unittest
-
from lib2to3 import pytree
from lib2to3.pgen2 import token
+import textwrap
+import unittest
from yapf.yapflib import format_token
from yapf.yapflib import split_penalty
from yapf.yapflib import unwrapped_line
-
from yapftests import yapf_test_helper
diff --git a/yapftests/yapf_test.py b/yapftests/yapf_test.py
index e3e3df3..08a01b8 100644
--- a/yapftests/yapf_test.py
+++ b/yapftests/yapf_test.py
@@ -15,6 +15,7 @@
"""Tests for yapf.yapf."""
import io
+from lib2to3.pgen2 import tokenize
import logging
import os
import shutil
@@ -24,12 +25,9 @@ import tempfile
import textwrap
import unittest
-from lib2to3.pgen2 import tokenize
-
from yapf.yapflib import py3compat
from yapf.yapflib import style
from yapf.yapflib import yapf_api
-
from yapftests import utils
from yapftests import yapf_test_helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment