apply pyfmt with usort to opted-in sources

Reviewed By: zertosh

Differential Revision: D24880203

fbshipit-source-id: 2034cdfc2712209e86d3d05c119c58f979b05c52
This commit is contained in:
John Reese 2020-11-10 21:23:10 -08:00 committed by Facebook GitHub Bot
parent 4f70ffdff8
commit d13e0b137f
21 changed files with 49 additions and 50 deletions

View File

@ -28,8 +28,8 @@ from .runcmd import run_cmd
try:
from urlparse import urlparse
from urllib import urlretrieve
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
from urllib.request import urlretrieve

View File

@ -218,8 +218,8 @@ class Overlay:
return (header, self.parse_dir_inode_data(data))
def parse_dir_inode_data(self, data: bytes) -> OverlayDir:
from thrift.util import Serializer
from thrift.protocol import TCompactProtocol
from thrift.util import Serializer
# Initialize entries to the empty dictionary.
# This value will be used if the serialized data does not have any value
@ -388,8 +388,8 @@ class Overlay:
self._write_inode(inode_number, OverlayHeader.TYPE_FILE, b"")
def write_empty_dir(self, inode_number: int) -> None:
from thrift.util import Serializer
from thrift.protocol import TCompactProtocol
from thrift.util import Serializer
empty_tree = OverlayDir()
protocol_factory = TCompactProtocol.TCompactProtocolFactory()

View File

@ -20,9 +20,10 @@ from .testcase import test_replicator
if sys.platform.startswith("linux"):
from .systemd import SystemdService, SystemdUserServiceManager, temp_systemd
from eden.fs.cli.systemd import edenfs_systemd_service_name
from .systemd import SystemdService, SystemdUserServiceManager, temp_systemd
try:
import pystemd # noqa: F401

View File

@ -406,10 +406,10 @@ def run(
):
manifest = os.path.abspath(manifest)
if is_libfb_present():
from libfb.py.log import set_simple_logging
from eden.mononoke.tests.integration.facebook.lib_runner import (
load_manifest_env,
)
from libfb.py.log import set_simple_logging
set_simple_logging(logging.INFO)
manifest_env: ManifestEnv = load_manifest_env(manifest)

View File

@ -174,8 +174,8 @@ else:
try:
import edemscm.mercurial.registrar
import edemscm.mercurial.configitems
import edemscm.mercurial.registrar
import edenscm.mercurial as mercurial
configtable = {}
@ -444,8 +444,8 @@ def perfdatapack(ui, repo, packpath, **opts):
def _packtestfn(ui, packpath, opts, func):
from edenscm.hgext.remotefilelog.datapack import datapack, fastdatapack
from bindings import revisionstore
from edenscm.hgext.remotefilelog.datapack import datapack, fastdatapack
kinds = [
("Python", datapack),

View File

@ -12,9 +12,10 @@ def _fixsys():
Fix sys.stdin if it's None.
"""
import os
# Do not expose those modules to edenscm.__dict__
import sys
import os
dirname = os.path.dirname

View File

@ -10,12 +10,11 @@ import gzip
import os
import socket
import ssl
import time
import tempfile
import time
from multiprocessing.pool import ThreadPool
from subprocess import PIPE, Popen
from edenscm.mercurial import error, json, perftrace, pycompat, util, commands
from edenscm.mercurial.i18n import _

View File

@ -42,6 +42,8 @@ NoRepo = common.NoRepo
# these bindings.
try:
import warnings
# pyre-fixme[21]: Could not find `svn`.
import svn
@ -51,13 +53,13 @@ try:
# pyre-fixme[21]: Could not find module `svn.core`.
import svn.core
# pyre-fixme[21]: Could not find module `svn.delta`.
import svn.delta
# pyre-fixme[21]: Could not find module `svn.ra`.
import svn.ra
# pyre-fixme[21]: Could not find module `svn.delta`.
import svn.delta
from . import transport
import warnings
warnings.filterwarnings("ignore", module="svn.core", category=DeprecationWarning)
svn.core.SubversionException # trigger import to catch error

View File

@ -116,8 +116,8 @@ def debugshell(ui, repo, *args, **opts):
def _startipython(ui, repo):
from IPython.terminal.ipapp import load_default_config
from IPython.terminal.embed import InteractiveShellEmbed
from IPython.terminal.ipapp import load_default_config
bannermsg = "loaded repo: %s\n" "using source: %s" % (
repo and repo.root or "(none)",

View File

@ -30,17 +30,13 @@ ispypy = r"__pypy__" in sys.builtin_module_names
if sys.version_info[0] < 3:
import cookielib
import cPickle as pickle
import httplib
import Queue as _queue
import SocketServer as socketserver
else:
import http.cookiejar as cookielib # noqa: F401
import http.client as httplib # noqa: F401
import http.cookiejar as cookielib # noqa: F401
import pickle # noqa: F401
import queue as _queue
import socketserver # noqa: F401

View File

@ -133,14 +133,10 @@ if sys.version_info[0] >= 3:
else:
import BaseHTTPServer
import CGIHTTPServer
import SimpleHTTPServer
import urllib2
import urllib
import urllib2
import urlparse
urlreq._registeraliases(

View File

@ -214,8 +214,8 @@ def check(pofile, fatal=True, warning=False):
########################################
if __name__ == "__main__":
import sys
import optparse
import sys
optparser = optparse.OptionParser(
"""%prog [options] pofile ...

View File

@ -18,6 +18,7 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import contextlib
import ctypes
import ctypes.util
@ -160,12 +161,10 @@ else:
ispypy = "PyPy" in sys.version
from distutils.core import setup
import distutils
from distutils import file_util
from distutils import log
from distutils.ccompiler import new_compiler
from distutils.core import Command, Extension
from distutils.dir_util import copy_tree
from distutils.dist import Distribution
from distutils.command.build import build
from distutils.command.build_ext import build_ext
from distutils.command.build_py import build_py
@ -173,13 +172,16 @@ from distutils.command.build_scripts import build_scripts
from distutils.command.install import install
from distutils.command.install_lib import install_lib
from distutils.command.install_scripts import install_scripts
from distutils.spawn import spawn, find_executable
from distutils import file_util
from distutils.core import Command, Extension
from distutils.core import setup
from distutils.dir_util import copy_tree
from distutils.dist import Distribution
from distutils.errors import CCompilerError, DistutilsError, DistutilsExecError
from distutils.spawn import spawn, find_executable
from distutils.sysconfig import get_config_var
from distutils.version import StrictVersion
from distutils_rust import RustBinary, BuildRustExt, InstallRustExt
import distutils
havefb = os.path.exists("fb")
isgetdepsbuild = os.environ.get("GETDEPS_BUILD") == "1"

View File

@ -96,12 +96,10 @@ def filter(f, it):
ispypy = "PyPy" in sys.version
from distutils.core import setup
import distutils
from distutils import file_util
from distutils import log
from distutils.ccompiler import new_compiler
from distutils.core import Command, Extension
from distutils.dir_util import copy_tree
from distutils.dist import Distribution
from distutils.command.build import build
from distutils.command.build_ext import build_ext
from distutils.command.build_py import build_py
@ -109,13 +107,16 @@ from distutils.command.build_scripts import build_scripts
from distutils.command.install import install
from distutils.command.install_lib import install_lib
from distutils.command.install_scripts import install_scripts
from distutils.spawn import spawn, find_executable
from distutils import file_util
from distutils.core import Command, Extension
from distutils.core import setup
from distutils.dir_util import copy_tree
from distutils.dist import Distribution
from distutils.errors import CCompilerError, DistutilsError, DistutilsExecError
from distutils.spawn import spawn, find_executable
from distutils.sysconfig import get_config_var
from distutils.version import StrictVersion
from distutils_rust import RustBinary, BuildRustExt, InstallRustExt
import distutils
havefb = os.path.exists("fb")
isgetdepsbuild = os.environ.get("GETDEPS_BUILD") == "1"

View File

@ -587,6 +587,7 @@ def has_defaultcacerts():
@check("defaultcacertsloaded", "detected presence of loaded system CA certs")
def has_defaultcacertsloaded():
import ssl
from edenscm.mercurial import sslutil, ui as uimod
if not has_defaultcacerts():

View File

@ -121,11 +121,11 @@ pygmentspresent = False
if os.name != "nt":
try: # is pygments installed
import pygments
import pygments.lexers as lexers
import pygments.lexer as lexer
import pygments.formatters as formatters
import pygments.token as token
import pygments.lexer as lexer
import pygments.lexers as lexers
import pygments.style as style
import pygments.token as token
pygmentspresent = True
difflexer = lexers.DiffLexer()

View File

@ -5,9 +5,10 @@ import os
if os.environ.get("COVERAGE_PROCESS_START"):
try:
import coverage
import uuid
import coverage
covpath = os.path.join(os.environ["COVERAGE_DIR"], "cov.%s" % uuid.uuid1())
cov = coverage.coverage(data_file=covpath, auto_data=True)
cov._warn_no_data = False

View File

@ -13,12 +13,11 @@ import os
import sys
import warnings
from edenscm.mercurial import namespaces
from edenscm.mercurial import pycompat
from testutil.autofix import eq
from testutil.dott import feature, sh, testtmp # noqa: F401
from edenscm.mercurial import namespaces
is_py3 = sys.version_info[0] >= 3
sh % "setconfig 'extensions.treemanifest=!'"

View File

@ -9,6 +9,7 @@ demandimport.enable()
import os
import subprocess
import sys
from hghave import require
require(["py2"])

View File

@ -6,11 +6,10 @@
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
import time
from edenscm.mercurial.extensions import wrappedfunction
import time
from testutil.dott import feature, sh, testtmp # noqa: F401
# Setup repo

View File

@ -52,8 +52,8 @@ def editsyspath(modname, relpaths):
# Soon, the only way to run this script is to via "hg debugpython" and
# all sys.path mess can be removed.
try:
from edenscmnative import diffhelpers
from edenscm import mercurial
from edenscmnative import diffhelpers
except (AttributeError, ImportError):
editsyspath("edenscm", ["..", "../../.."])
@ -72,8 +72,8 @@ if DUMMYSSH is None:
try:
from edenscm.mercurial import encoding, util, pycompat
import bindings
from edenscm.mercurial import encoding, util, pycompat
except ImportError:
raise RuntimeError("Cannot find edenscm")