Skip to content

Instantly share code, notes, and snippets.

@timothycrosley
Created October 2, 2020 06:07
Show Gist options
  • Save timothycrosley/56eda241c0d92a25b4b0afba03621ae0 to your computer and use it in GitHub Desktop.
Save timothycrosley/56eda241c0d92a25b4b0afba03621ae0 to your computer and use it in GitHub Desktop.
abseil-py after isort is ran
diff --git a/absl/_enum_module.py b/absl/_enum_module.py
index 899c488..c12e1d8 100644
--- a/absl/_enum_module.py
+++ b/absl/_enum_module.py
@@ -41,6 +41,7 @@ the following is true:
"""
# pylint: disable=unused-import
import sys
+
import six
try:
diff --git a/absl/flags/__init__.py b/absl/flags/__init__.py
index a82986b..4b15a07 100644
--- a/absl/flags/__init__.py
+++ b/absl/flags/__init__.py
@@ -36,6 +36,8 @@ import sys
import types
import warnings
+import six
+
from absl.flags import _argument_parser
from absl.flags import _defines
from absl.flags import _exceptions
@@ -43,7 +45,6 @@ from absl.flags import _flag
from absl.flags import _flagvalues
from absl.flags import _helpers
from absl.flags import _validators
-import six
# Initialize the FLAGS_MODULE as early as possible.
# It's only used by adopt_module_key_flags to take SPECIAL_FLAGS into account.
diff --git a/absl/flags/_argument_parser.py b/absl/flags/_argument_parser.py
index a706191..6acaa3b 100644
--- a/absl/flags/_argument_parser.py
+++ b/absl/flags/_argument_parser.py
@@ -27,9 +27,10 @@ import csv
import io
import string
-from absl.flags import _helpers
import six
+from absl.flags import _helpers
+
def _is_integer_type(instance):
"""Returns True if instance is an integer, and not a bool."""
diff --git a/absl/flags/_argument_parser.pyi b/absl/flags/_argument_parser.pyi
index 62f6738..520d5a6 100644
--- a/absl/flags/_argument_parser.pyi
+++ b/absl/flags/_argument_parser.pyi
@@ -15,9 +15,9 @@
"""Contains type annotations for _argument_parser.py."""
-from typing import Text, TypeVar, Generic, Iterable, Type, List, Optional, Sequence, Any
-
import enum
+from typing import (Any, Generic, Iterable, List, Optional, Sequence, Text,
+ Type, TypeVar)
_T = TypeVar('_T')
_ET = TypeVar('_ET', bound=enum.Enum)
diff --git a/absl/flags/_defines.py b/absl/flags/_defines.py
index a8d5470..0ef7806 100644
--- a/absl/flags/_defines.py
+++ b/absl/flags/_defines.py
@@ -33,7 +33,7 @@ from absl.flags import _validators
# pylint: disable=unused-import
try:
- from typing import Text, List, Any
+ from typing import Any, List, Text
except ImportError:
pass
diff --git a/absl/flags/_defines.pyi b/absl/flags/_defines.pyi
index 5949f0a..95a489e 100644
--- a/absl/flags/_defines.pyi
+++ b/absl/flags/_defines.pyi
@@ -14,14 +14,14 @@
"""This modules contains type annotated stubs for DEFINE functions."""
+import enum
+from typing import (Any, Iterable, List, Optional, overload, Text, Type,
+ TypeVar, Union)
+
from absl.flags import _argument_parser
from absl.flags import _flag
from absl.flags import _flagvalues
-import enum
-
-from typing import Text, List, Any, TypeVar, Optional, Union, Type, Iterable, overload
-
_T = TypeVar('_T')
_ET = TypeVar('_ET', bound=enum.Enum)
diff --git a/absl/flags/_exceptions.py b/absl/flags/_exceptions.py
index 254eb9b..56501db 100644
--- a/absl/flags/_exceptions.py
+++ b/absl/flags/_exceptions.py
@@ -26,7 +26,6 @@ import sys
from absl.flags import _helpers
-
_helpers.disclaim_module_ids.add(id(sys.modules[__name__]))
diff --git a/absl/flags/_flag.py b/absl/flags/_flag.py
index a893b22..f3a0956 100644
--- a/absl/flags/_flag.py
+++ b/absl/flags/_flag.py
@@ -25,11 +25,12 @@ from __future__ import print_function
import copy
import functools
+import six
+
from absl._collections_abc import abc
from absl.flags import _argument_parser
from absl.flags import _exceptions
from absl.flags import _helpers
-import six
@functools.total_ordering
diff --git a/absl/flags/_flag.pyi b/absl/flags/_flag.pyi
index 9629c54..995503c 100644
--- a/absl/flags/_flag.pyi
+++ b/absl/flags/_flag.pyi
@@ -15,14 +15,15 @@
"""Contains type annotations for Flag class."""
import copy
+import enum
import functools
+from typing import (Any, Generic, Iterable, List, Optional, Sequence, Text,
+ Type, TypeVar, Union)
-from absl._collections_abc import abc
-from absl.flags import _argument_parser
-import enum
import six
-from typing import Text, TypeVar, Generic, Iterable, Type, List, Optional, Any, Union, Sequence
+from absl._collections_abc import abc
+from absl.flags import _argument_parser
_T = TypeVar('_T')
_ET = TypeVar('_ET', bound=enum.Enum)
diff --git a/absl/flags/_flagvalues.py b/absl/flags/_flagvalues.py
index 72a747c..6a2da88 100644
--- a/absl/flags/_flagvalues.py
+++ b/absl/flags/_flagvalues.py
@@ -28,15 +28,16 @@ import os
import sys
from xml.dom import minidom
+import six
+
from absl.flags import _exceptions
from absl.flags import _flag
from absl.flags import _helpers
-import six
# pylint: disable=unused-import
try:
import typing
- from typing import Text, Optional
+ from typing import Optional, Text
except ImportError:
typing = None
# pylint: enable=unused-import
diff --git a/absl/flags/_flagvalues.pyi b/absl/flags/_flagvalues.pyi
index e2aa14b..069e056 100644
--- a/absl/flags/_flagvalues.pyi
+++ b/absl/flags/_flagvalues.pyi
@@ -15,11 +15,11 @@
"""Defines type annotations for _flagvalues."""
-from absl.flags import _flag
-import six
+from typing import Any, Dict, Generic, List, Optional, Text, Type, TypeVar
-from typing import Text, Optional, TypeVar, Generic, Any, Dict, List, Type
+import six
+from absl.flags import _flag
# There is a lot of magic going on in FlagValues, so we just document the
# magic methods defined and make it loose, so this doesn't get in the way of
diff --git a/absl/flags/_helpers.py b/absl/flags/_helpers.py
index 68b8cfc..f898f34 100644
--- a/absl/flags/_helpers.py
+++ b/absl/flags/_helpers.py
@@ -24,6 +24,7 @@ import re
import struct
import sys
import textwrap
+
try:
import fcntl
except ImportError:
@@ -37,7 +38,6 @@ except ImportError:
import six
from six.moves import range # pylint: disable=redefined-builtin
-
_DEFAULT_HELP_WIDTH = 80 # Default width of help output.
_MIN_HELP_WIDTH = 40 # Minimal "sane" width of help output. We assume that any
# value below 40 is unreasonable.
diff --git a/absl/flags/argparse_flags.py b/absl/flags/argparse_flags.py
index bcd40f5..f62abaa 100644
--- a/absl/flags/argparse_flags.py
+++ b/absl/flags/argparse_flags.py
@@ -98,7 +98,6 @@ import sys
from absl import flags
-
_BUILT_IN_FLAGS = frozenset({
'help',
'helpshort',
diff --git a/absl/flags/tests/_argument_parser_test.py b/absl/flags/tests/_argument_parser_test.py
index e62c903..5e2fc0c 100644
--- a/absl/flags/tests/_argument_parser_test.py
+++ b/absl/flags/tests/_argument_parser_test.py
@@ -20,11 +20,12 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+import six
+
from absl._enum_module import enum
from absl.flags import _argument_parser
from absl.testing import absltest
from absl.testing import parameterized
-import six
class ArgumentParserTest(absltest.TestCase):
diff --git a/absl/flags/tests/_flagvalues_test.py b/absl/flags/tests/_flagvalues_test.py
index 658ec69..d104d9d 100644
--- a/absl/flags/tests/_flagvalues_test.py
+++ b/absl/flags/tests/_flagvalues_test.py
@@ -24,6 +24,9 @@ import pickle
import types
import unittest
+import mock
+import six
+
from absl import logging
from absl.flags import _defines
from absl.flags import _exceptions
@@ -33,8 +36,6 @@ from absl.flags import _validators
from absl.flags.tests import module_foo
from absl.testing import absltest
from absl.testing import parameterized
-import mock
-import six
class FlagValuesTest(absltest.TestCase):
diff --git a/absl/flags/tests/_validators_test.py b/absl/flags/tests/_validators_test.py
index a5dec45..43ee0c9 100644
--- a/absl/flags/tests/_validators_test.py
+++ b/absl/flags/tests/_validators_test.py
@@ -24,7 +24,6 @@ from __future__ import print_function
import warnings
-
from absl.flags import _defines
from absl.flags import _exceptions
from absl.flags import _flagvalues
diff --git a/absl/flags/tests/argparse_flags_test.py b/absl/flags/tests/argparse_flags_test.py
index 09272e8..15d64ee 100644
--- a/absl/flags/tests/argparse_flags_test.py
+++ b/absl/flags/tests/argparse_flags_test.py
@@ -23,15 +23,15 @@ import subprocess
import sys
import tempfile
+import mock
+import six
+
from absl import flags
from absl import logging
from absl.flags import argparse_flags
from absl.testing import _bazelize_command
from absl.testing import absltest
from absl.testing import parameterized
-import mock
-import six
-
FLAGS = flags.FLAGS
diff --git a/absl/flags/tests/flags_helpxml_test.py b/absl/flags/tests/flags_helpxml_test.py
index 92b59bb..d4b6024 100644
--- a/absl/flags/tests/flags_helpxml_test.py
+++ b/absl/flags/tests/flags_helpxml_test.py
@@ -25,12 +25,13 @@ import sys
import xml.dom.minidom
import xml.sax.saxutils
+import six
+
from absl import flags
from absl._enum_module import enum
from absl.flags import _helpers
from absl.flags.tests import module_bar
from absl.testing import absltest
-import six
class CreateXMLDOMElement(absltest.TestCase):
diff --git a/absl/flags/tests/flags_numeric_bounds_test.py b/absl/flags/tests/flags_numeric_bounds_test.py
index 5743258..f8ccae8 100644
--- a/absl/flags/tests/flags_numeric_bounds_test.py
+++ b/absl/flags/tests/flags_numeric_bounds_test.py
@@ -18,10 +18,11 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+import mock
+
from absl import flags
from absl.flags import _validators
from absl.testing import absltest
-import mock
class NumericFlagBoundsTest(absltest.TestCase):
diff --git a/absl/flags/tests/flags_test.py b/absl/flags/tests/flags_test.py
index 8608f2f..be8a5d0 100644
--- a/absl/flags/tests/flags_test.py
+++ b/absl/flags/tests/flags_test.py
@@ -26,6 +26,8 @@ import sys
import tempfile
import unittest
+import six
+
from absl import flags
from absl._enum_module import enum
from absl.flags import _exceptions
@@ -34,8 +36,6 @@ from absl.flags.tests import module_bar
from absl.flags.tests import module_baz
from absl.flags.tests import module_foo
from absl.testing import absltest
-import six
-
FLAGS = flags.FLAGS
diff --git a/absl/flags/tests/flags_unicode_literals_test.py b/absl/flags/tests/flags_unicode_literals_test.py
index e8ed5bf..ebb08cf 100644
--- a/absl/flags/tests/flags_unicode_literals_test.py
+++ b/absl/flags/tests/flags_unicode_literals_test.py
@@ -22,7 +22,6 @@ from __future__ import unicode_literals
from absl import flags
from absl.testing import absltest
-
flags.DEFINE_string('seen_in_crittenden', 'alleged mountain lion',
'This tests if unicode input to these functions works.')
diff --git a/absl/logging/__init__.py b/absl/logging/__init__.py
index bd06cdd..1f1a650 100644
--- a/absl/logging/__init__.py
+++ b/absl/logging/__init__.py
@@ -90,10 +90,11 @@ import traceback
import types
import warnings
+import six
+
from absl import flags
from absl._collections_abc import abc
from absl.logging import converter
-import six
if six.PY2:
import thread as _thread_lib # For .get_ident().
diff --git a/absl/logging/tests/log_before_import_test.py b/absl/logging/tests/log_before_import_test.py
index d1ba61f..02ac9ef 100644
--- a/absl/logging/tests/log_before_import_test.py
+++ b/absl/logging/tests/log_before_import_test.py
@@ -25,9 +25,10 @@ import re
import sys
import tempfile
+import mock
+
from absl import logging
from absl.testing import absltest
-import mock
logging.get_verbosity() # Access --verbosity before flag parsing.
# Access --logtostderr before flag parsing.
diff --git a/absl/logging/tests/logging_functional_test.py b/absl/logging/tests/logging_functional_test.py
index b8c79d3..3e6dfa5 100755
--- a/absl/logging/tests/logging_functional_test.py
+++ b/absl/logging/tests/logging_functional_test.py
@@ -26,12 +26,13 @@ import subprocess
import sys
import tempfile
+import six
+
from absl import flags
from absl import logging
from absl.testing import _bazelize_command
from absl.testing import absltest
from absl.testing import parameterized
-import six
FLAGS = flags.FLAGS
diff --git a/absl/logging/tests/logging_functional_test_helper.py b/absl/logging/tests/logging_functional_test_helper.py
index aae5763..b81210b 100755
--- a/absl/logging/tests/logging_functional_test_helper.py
+++ b/absl/logging/tests/logging_functional_test_helper.py
@@ -25,11 +25,12 @@ import threading
import time
import timeit
+import mock
+from six.moves import xrange # pylint: disable=redefined-builtin
+
from absl import app
from absl import flags
from absl import logging
-import mock
-from six.moves import xrange # pylint: disable=redefined-builtin
FLAGS = flags.FLAGS
diff --git a/absl/logging/tests/logging_test.py b/absl/logging/tests/logging_test.py
index 290b2f3..1f055cf 100644
--- a/absl/logging/tests/logging_test.py
+++ b/absl/logging/tests/logging_test.py
@@ -33,14 +33,15 @@ import time
import traceback
import unittest
+import mock
+import six
+from six.moves import range # pylint: disable=redefined-builtin
+
from absl import flags
from absl import logging
from absl.testing import absltest
from absl.testing import flagsaver
from absl.testing import parameterized
-import mock
-import six
-from six.moves import range # pylint: disable=redefined-builtin
FLAGS = flags.FLAGS
diff --git a/absl/testing/_pretty_print_reporter.py b/absl/testing/_pretty_print_reporter.py
index 913e509..e679345 100644
--- a/absl/testing/_pretty_print_reporter.py
+++ b/absl/testing/_pretty_print_reporter.py
@@ -19,6 +19,7 @@ from __future__ import division
from __future__ import print_function
import unittest
+
from absl.third_party import unittest3_backport
diff --git a/absl/testing/absltest.py b/absl/testing/absltest.py
index 3b78eb9..2ed8278 100644
--- a/absl/testing/absltest.py
+++ b/absl/testing/absltest.py
@@ -48,11 +48,16 @@ try:
# understand that we're catching ImportError, so suppress the error.
# pytype: disable=import-error
import faulthandler
+
# pytype: enable=import-error
except ImportError:
# We use faulthandler if it is available.
faulthandler = None
+import six
+from six.moves import urllib
+from six.moves import xrange # pylint: disable=redefined-builtin
+
from absl import app
from absl import flags
from absl import logging
@@ -61,16 +66,16 @@ from absl._enum_module import enum
from absl.testing import _pretty_print_reporter
from absl.testing import xml_reporter
from absl.third_party import unittest3_backport
-import six
-from six.moves import urllib
-from six.moves import xrange # pylint: disable=redefined-builtin
# Make typing an optional import to avoid it being a required dependency
# in Python 2. Type checkers will still understand the imports.
try:
# pylint: disable=unused-import
import typing
- from typing import Any, AnyStr, BinaryIO, Callable, ContextManager, IO, Iterator, List, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Text, TextIO, Tuple, Type, Union
+ from typing import (Any, AnyStr, BinaryIO, Callable, ContextManager, IO,
+ Iterator, List, Mapping, MutableMapping, MutableSequence,
+ Optional, Sequence, Text, TextIO, Tuple, Type, Union)
+
# pylint: enable=unused-import
except ImportError:
pass
diff --git a/absl/testing/flagsaver.py b/absl/testing/flagsaver.py
index 9a0e193..07c8bee 100755
--- a/absl/testing/flagsaver.py
+++ b/absl/testing/flagsaver.py
@@ -61,9 +61,10 @@ from __future__ import print_function
import functools
import inspect
-from absl import flags
import six
+from absl import flags
+
FLAGS = flags.FLAGS
diff --git a/absl/testing/parameterized.py b/absl/testing/parameterized.py
index 46b6b48..acff8d8 100755
--- a/absl/testing/parameterized.py
+++ b/absl/testing/parameterized.py
@@ -182,9 +182,10 @@ import re
import types
import unittest
+import six
+
from absl._collections_abc import abc
from absl.testing import absltest
-import six
try:
from absl.testing import _parameterized_async
diff --git a/absl/testing/tests/absltest_randomization_testcase.py b/absl/testing/tests/absltest_randomization_testcase.py
index 18b20ff..f50cac6 100644
--- a/absl/testing/tests/absltest_randomization_testcase.py
+++ b/absl/testing/tests/absltest_randomization_testcase.py
@@ -23,7 +23,6 @@ import sys
from absl.testing import absltest
-
# This stanza exercises setting $TEST_RANDOMIZE_ORDERING_SEED *after* importing
# the absltest library.
if os.environ.get('LATE_SET_TEST_RANDOMIZE_ORDERING_SEED', ''):
diff --git a/absl/testing/tests/absltest_test.py b/absl/testing/tests/absltest_test.py
index 2e7f1be..26d4dff 100644
--- a/absl/testing/tests/absltest_test.py
+++ b/absl/testing/tests/absltest_test.py
@@ -28,11 +28,12 @@ import subprocess
import sys
import tempfile
+import six
+
from absl import flags
from absl.testing import _bazelize_command
from absl.testing import absltest
from absl.testing import parameterized
-import six
try:
import pathlib
diff --git a/absl/testing/tests/parameterized_test.py b/absl/testing/tests/parameterized_test.py
index b75068a..97a1c1b 100755
--- a/absl/testing/tests/parameterized_test.py
+++ b/absl/testing/tests/parameterized_test.py
@@ -21,11 +21,12 @@ from __future__ import print_function
import sys
import unittest
+import six
+from six.moves import range # pylint: disable=redefined-builtin
+
from absl._collections_abc import abc
from absl.testing import absltest
from absl.testing import parameterized
-import six
-from six.moves import range # pylint: disable=redefined-builtin
class MyOwnClass(object):
diff --git a/absl/testing/tests/xml_reporter_helper_test.py b/absl/testing/tests/xml_reporter_helper_test.py
index 661bbdc..bf22b5b 100644
--- a/absl/testing/tests/xml_reporter_helper_test.py
+++ b/absl/testing/tests/xml_reporter_helper_test.py
@@ -21,7 +21,6 @@ import random
from absl import flags
from absl.testing import absltest
-
FLAGS = flags.FLAGS
flags.DEFINE_boolean('set_up_module_error', False,
'Cause setupModule to error.')
diff --git a/absl/testing/tests/xml_reporter_test.py b/absl/testing/tests/xml_reporter_test.py
index a7c3f9d..d4dc0ec 100755
--- a/absl/testing/tests/xml_reporter_test.py
+++ b/absl/testing/tests/xml_reporter_test.py
@@ -28,14 +28,15 @@ import unittest
from xml.etree import ElementTree
from xml.parsers import expat
+import mock
+import six
+
from absl import logging
from absl.testing import _bazelize_command
from absl.testing import absltest
from absl.testing import parameterized
from absl.testing import xml_reporter
from absl.third_party import unittest3_backport
-import mock
-import six
class StringIOWriteLn(six.StringIO):
diff --git a/absl/testing/xml_reporter.py b/absl/testing/xml_reporter.py
index 792977f..0903314 100755
--- a/absl/testing/xml_reporter.py
+++ b/absl/testing/xml_reporter.py
@@ -26,10 +26,11 @@ import time
import traceback
import unittest
from xml.sax import saxutils
-from absl.testing import _pretty_print_reporter
-from absl.third_party import unittest3_backport
+
import six
+from absl.testing import _pretty_print_reporter
+from absl.third_party import unittest3_backport
# See http://www.w3.org/TR/REC-xml/#NT-Char
_bad_control_character_codes = set(range(0, 0x20)) - {0x9, 0xA, 0xD}
diff --git a/absl/tests/app_test.py b/absl/tests/app_test.py
index 9494979..c46cb22 100644
--- a/absl/tests/app_test.py
+++ b/absl/tests/app_test.py
@@ -28,6 +28,9 @@ import sys
import tempfile
import unittest
+import mock
+import six
+
from absl import app
from absl import flags
from absl._enum_module import enum
@@ -35,9 +38,6 @@ from absl.testing import _bazelize_command
from absl.testing import absltest
from absl.testing import flagsaver
from absl.tests import app_test_helper
-import mock
-import six
-
FLAGS = flags.FLAGS
diff --git a/absl/tests/command_name_test.py b/absl/tests/command_name_test.py
index 61af1bb..0c8be13 100644
--- a/absl/tests/command_name_test.py
+++ b/absl/tests/command_name_test.py
@@ -24,9 +24,10 @@ import errno
import os
import unittest
+import mock
+
from absl import command_name
from absl.testing import absltest
-import mock
def _get_kernel_process_name():
diff --git a/absl/third_party/unittest3_backport/tests/unittest3_backport_test.py b/absl/third_party/unittest3_backport/tests/unittest3_backport_test.py
index b18d4cb..49f9a6c 100644
--- a/absl/third_party/unittest3_backport/tests/unittest3_backport_test.py
+++ b/absl/third_party/unittest3_backport/tests/unittest3_backport_test.py
@@ -6,11 +6,12 @@ from __future__ import print_function
import unittest
-from absl.testing import absltest
-from absl.testing import xml_reporter
import mock
import six
+from absl.testing import absltest
+from absl.testing import xml_reporter
+
class MockTestResult(xml_reporter._TextAndXMLTestResult):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment