From f2b7d4ed4f5aa237d00bcddd21248fcee0f7b9d8 Mon Sep 17 00:00:00 2001 From: Noortheen Raja Date: Thu, 24 Mar 2022 00:46:50 +0530 Subject: [PATCH] style: sort imports --- pyproject.toml | 3 ++- tests/completers/test_base_completer.py | 2 +- tests/completers/test_bash_completer.py | 2 +- tests/completers/test_command_completers.py | 2 +- tests/completers/test_dir_completers.py | 2 +- tests/completers/test_python.py | 2 +- tests/procs/test_specs.py | 2 +- tests/test_aliases.py | 2 +- tests/test_ast.py | 2 +- tests/test_builtins.py | 2 +- tests/test_commands_cache.py | 2 +- tests/test_completion_context.py | 2 +- tests/test_environ.py | 2 +- tests/test_foreign_shells.py | 2 +- tests/test_integrations.py | 2 +- tests/test_main.py | 2 +- tests/test_man.py | 2 +- tests/test_parser.py | 6 +++--- tests/test_pipelines.py | 2 +- tests/test_ptk_highlight.py | 2 +- tests/test_ptk_shell.py | 2 +- tests/test_tools.py | 2 +- tests/test_vox.py | 2 +- xonsh/pytest/plugin.py | 1 + xonsh/shell.py | 2 +- xonsh/xonfig.py | 5 ++--- 26 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b98ddd61d..05468a884 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,4 +42,5 @@ force_exclude = '''.*/__amalgam__.py''' profile = "black" extend_skip_glob = ["xonsh/*_table.py", "xonsh/ply/**.py", "*/__amalgam__.py", "**/__amalgam__.py"] src_paths = ["xonsh", "xontrib", "xompletions", "tests"] -known_third_party = ["ply"] +known_first_party = ["xonsh", "xontrib", "xompletions", "tests"] +known_third_party = ["ply", "pytest"] diff --git a/tests/completers/test_base_completer.py b/tests/completers/test_base_completer.py index 4d8c4248a..da9cbf5af 100644 --- a/tests/completers/test_base_completer.py +++ b/tests/completers/test_base_completer.py @@ -1,8 +1,8 @@ import pytest -from xonsh.pytest.tools import ON_WINDOWS from xonsh.completers.base import complete_base from xonsh.parsers.completion_context import CommandContext, CompletionContext +from xonsh.pytest.tools import ON_WINDOWS CUR_DIR = ( "." if ON_WINDOWS else "./" diff --git a/tests/completers/test_bash_completer.py b/tests/completers/test_bash_completer.py index d9c2676c5..002ff6042 100644 --- a/tests/completers/test_bash_completer.py +++ b/tests/completers/test_bash_completer.py @@ -1,6 +1,5 @@ import pytest -from xonsh.pytest.tools import skip_if_on_darwin, skip_if_on_windows from xonsh.completers.bash import complete_from_bash from xonsh.completers.tools import RichCompletion from xonsh.parsers.completion_context import ( @@ -8,6 +7,7 @@ from xonsh.parsers.completion_context import ( CommandContext, CompletionContext, ) +from xonsh.pytest.tools import skip_if_on_darwin, skip_if_on_windows @pytest.fixture(autouse=True) diff --git a/tests/completers/test_command_completers.py b/tests/completers/test_command_completers.py index 8cc1245e0..a654aba75 100644 --- a/tests/completers/test_command_completers.py +++ b/tests/completers/test_command_completers.py @@ -2,7 +2,6 @@ from unittest.mock import Mock import pytest -from xonsh.pytest.tools import ON_WINDOWS, completions_from_result, skip_if_on_windows from xonsh.completer import Completer from xonsh.completers.commands import complete_command, complete_skipper from xonsh.parsers.completion_context import ( @@ -10,6 +9,7 @@ from xonsh.parsers.completion_context import ( CommandContext, CompletionContext, ) +from xonsh.pytest.tools import ON_WINDOWS, completions_from_result, skip_if_on_windows @pytest.fixture(autouse=True) diff --git a/tests/completers/test_dir_completers.py b/tests/completers/test_dir_completers.py index 3505097c7..53284227a 100644 --- a/tests/completers/test_dir_completers.py +++ b/tests/completers/test_dir_completers.py @@ -3,8 +3,8 @@ from os import sep import pytest -from xonsh.pytest.tools import ON_WINDOWS from xonsh.completers.tools import RichCompletion +from xonsh.pytest.tools import ON_WINDOWS CUR_DIR = "." if ON_WINDOWS else "./" PARENT_DIR = ".." if ON_WINDOWS else "../" diff --git a/tests/completers/test_python.py b/tests/completers/test_python.py index 5e822c526..265c3fcb0 100644 --- a/tests/completers/test_python.py +++ b/tests/completers/test_python.py @@ -1,9 +1,9 @@ import pytest -from xonsh.pytest.tools import skip_if_pre_3_8 from xonsh.completers.imports import complete_import from xonsh.completers.python import complete_python, python_signature_complete from xonsh.parsers.completion_context import CompletionContext, PythonContext +from xonsh.pytest.tools import skip_if_pre_3_8 @pytest.fixture(autouse=True) diff --git a/tests/procs/test_specs.py b/tests/procs/test_specs.py index b9b2fbe29..4c09c6d56 100644 --- a/tests/procs/test_specs.py +++ b/tests/procs/test_specs.py @@ -5,10 +5,10 @@ from subprocess import Popen import pytest -from xonsh.pytest.tools import skip_if_on_windows from xonsh.procs.posix import PopenThread from xonsh.procs.proxies import STDOUT_DISPATCHER, ProcProxy, ProcProxyThread from xonsh.procs.specs import cmds_to_specs, run_subproc +from xonsh.pytest.tools import skip_if_on_windows @skip_if_on_windows diff --git a/tests/test_aliases.py b/tests/test_aliases.py index 5c58c7fdb..911b2f047 100644 --- a/tests/test_aliases.py +++ b/tests/test_aliases.py @@ -5,8 +5,8 @@ import os import pytest -from xonsh.pytest.tools import skip_if_on_windows from xonsh.aliases import Aliases, ExecAlias +from xonsh.pytest.tools import skip_if_on_windows def cd(args, stdin=None, **kwargs): diff --git a/tests/test_ast.py b/tests/test_ast.py index 1af66bccb..611ea8d24 100644 --- a/tests/test_ast.py +++ b/tests/test_ast.py @@ -3,9 +3,9 @@ import ast as pyast import pytest -from xonsh.pytest.tools import nodes_equal from xonsh import ast from xonsh.ast import BinOp, Call, Name, Store, Tuple, isexpression, min_line +from xonsh.pytest.tools import nodes_equal @pytest.fixture(autouse=True) diff --git a/tests/test_builtins.py b/tests/test_builtins.py index 3a2df0614..57e866881 100644 --- a/tests/test_builtins.py +++ b/tests/test_builtins.py @@ -8,7 +8,6 @@ from pathlib import Path import pytest -from xonsh.pytest.tools import skip_if_on_windows from xonsh.built_ins import ( call_macro, convert_macro_arg, @@ -25,6 +24,7 @@ from xonsh.built_ins import ( superhelper, ) from xonsh.environ import Env +from xonsh.pytest.tools import skip_if_on_windows HOME_PATH = os.path.expanduser("~") diff --git a/tests/test_commands_cache.py b/tests/test_commands_cache.py index 9911ae169..be766aea2 100644 --- a/tests/test_commands_cache.py +++ b/tests/test_commands_cache.py @@ -5,7 +5,6 @@ from unittest.mock import MagicMock import pytest -from xonsh.pytest.tools import skip_if_on_windows from xonsh.commands_cache import ( SHELL_PREDICTOR_PARSER, CommandsCache, @@ -13,6 +12,7 @@ from xonsh.commands_cache import ( predict_shell, predict_true, ) +from xonsh.pytest.tools import skip_if_on_windows def test_commands_cache_lazy(xession): diff --git a/tests/test_completion_context.py b/tests/test_completion_context.py index 1cec2f3ec..b3cde66b8 100644 --- a/tests/test_completion_context.py +++ b/tests/test_completion_context.py @@ -5,13 +5,13 @@ from unittest import mock import pytest import xonsh.parsers.completion_context as ctx -from xonsh.pytest.tools import ON_WINDOWS from xonsh.parsers.completion_context import ( CommandArg, CommandContext, CompletionContextParser, PythonContext, ) +from xonsh.pytest.tools import ON_WINDOWS DEBUG = False MISSING = object() diff --git a/tests/test_environ.py b/tests/test_environ.py index 57b55af33..611e4a1dc 100644 --- a/tests/test_environ.py +++ b/tests/test_environ.py @@ -10,7 +10,6 @@ from time import sleep import pytest -from xonsh.pytest.tools import skip_if_on_unix from xonsh.environ import ( Env, InternalEnvironDict, @@ -21,6 +20,7 @@ from xonsh.environ import ( locate_binary, make_args_env, ) +from xonsh.pytest.tools import skip_if_on_unix from xonsh.tools import DefaultNotGiven, always_true diff --git a/tests/test_foreign_shells.py b/tests/test_foreign_shells.py index 9ff8f16d9..5f5a9489c 100644 --- a/tests/test_foreign_shells.py +++ b/tests/test_foreign_shells.py @@ -4,8 +4,8 @@ import subprocess import pytest # noqa F401 -from xonsh.pytest.tools import skip_if_on_unix, skip_if_on_windows from xonsh.foreign_shells import foreign_shell_data, parse_aliases, parse_env +from xonsh.pytest.tools import skip_if_on_unix, skip_if_on_windows def test_parse_env(): diff --git a/tests/test_integrations.py b/tests/test_integrations.py index 46fea540e..c6195c688 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -10,6 +10,7 @@ from pathlib import Path import pytest import xonsh +from xonsh.dirstack import with_pushd from xonsh.pytest.tools import ( ON_DARWIN, ON_TRAVIS, @@ -19,7 +20,6 @@ from xonsh.pytest.tools import ( skip_if_on_unix, skip_if_on_windows, ) -from xonsh.dirstack import with_pushd PATH = ( os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin") diff --git a/tests/test_main.py b/tests/test_main.py index 83c055468..698a78be9 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -9,8 +9,8 @@ from contextlib import contextmanager import pytest import xonsh.main -from xonsh.pytest.tools import ON_WINDOWS, TEST_DIR, skip_if_on_windows from xonsh.main import XonshMode +from xonsh.pytest.tools import ON_WINDOWS, TEST_DIR, skip_if_on_windows def Shell(*args, **kwargs): diff --git a/tests/test_man.py b/tests/test_man.py index 7c6689260..674c7caed 100644 --- a/tests/test_man.py +++ b/tests/test_man.py @@ -3,8 +3,8 @@ import subprocess import pytest # noqa F401 -from xonsh.pytest.tools import skip_if_not_on_darwin, skip_if_on_windows from xonsh.completers.man import complete_from_man +from xonsh.pytest.tools import skip_if_not_on_darwin, skip_if_on_windows @skip_if_on_windows diff --git a/tests/test_parser.py b/tests/test_parser.py index 3fc54b969..400b6c964 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -5,15 +5,15 @@ import textwrap import pytest +from xonsh.ast import AST, Call, Pass, Str, With +from xonsh.parser import Parser +from xonsh.parsers.fstring_adaptor import FStringAdaptor from xonsh.pytest.tools import ( VER_MAJOR_MINOR, nodes_equal, skip_if_pre_3_8, skip_if_pre_3_10, ) -from xonsh.ast import AST, Call, Pass, Str, With -from xonsh.parser import Parser -from xonsh.parsers.fstring_adaptor import FStringAdaptor @pytest.fixture diff --git a/tests/test_pipelines.py b/tests/test_pipelines.py index 327399474..910e75036 100644 --- a/tests/test_pipelines.py +++ b/tests/test_pipelines.py @@ -6,9 +6,9 @@ import os import pytest -from xonsh.pytest.tools import skip_if_on_unix, skip_if_on_windows from xonsh.platform import ON_WINDOWS from xonsh.procs.pipelines import CommandPipeline +from xonsh.pytest.tools import skip_if_on_unix, skip_if_on_windows @pytest.fixture(autouse=True) diff --git a/tests/test_ptk_highlight.py b/tests/test_ptk_highlight.py index 63e58bfa4..be8f017f0 100644 --- a/tests/test_ptk_highlight.py +++ b/tests/test_ptk_highlight.py @@ -14,10 +14,10 @@ from pygments.token import ( Text, ) -from xonsh.pytest.tools import DummyShell, skip_if_on_windows from xonsh.environ import LsColors from xonsh.events import EventManager, events from xonsh.pyghooks import Color, XonshLexer, XonshStyle, on_lscolors_change +from xonsh.pytest.tools import DummyShell, skip_if_on_windows @pytest.fixture diff --git a/tests/test_ptk_shell.py b/tests/test_ptk_shell.py index 19934f525..bd1ebaef4 100644 --- a/tests/test_ptk_shell.py +++ b/tests/test_ptk_shell.py @@ -5,9 +5,9 @@ import sys import pyte import pytest -from xonsh.pytest.tools import ON_WINDOWS from xonsh.platform import minimum_required_ptk_version from xonsh.ptk_shell.shell import tokenize_ansi +from xonsh.pytest.tools import ON_WINDOWS from xonsh.shell import Shell # verify error if ptk not installed or below min diff --git a/tests/test_tools.py b/tests/test_tools.py index 872c140fc..eaff3a130 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -8,10 +8,10 @@ from tempfile import TemporaryDirectory import pytest -from xonsh.pytest.tools import skip_if_on_windows from xonsh import __version__ from xonsh.lexer import Lexer from xonsh.platform import HAS_PYGMENTS, ON_WINDOWS +from xonsh.pytest.tools import skip_if_on_windows from xonsh.tools import ( EnvPath, all_permutations, diff --git a/tests/test_vox.py b/tests/test_vox.py index d8cb81458..06514496e 100644 --- a/tests/test_vox.py +++ b/tests/test_vox.py @@ -9,8 +9,8 @@ from typing import TYPE_CHECKING import pytest -from xonsh.pytest.tools import skip_if_on_conda, skip_if_on_msys from xonsh.platform import ON_WINDOWS +from xonsh.pytest.tools import skip_if_on_conda, skip_if_on_msys from xontrib.voxapi import Vox if TYPE_CHECKING: diff --git a/xonsh/pytest/plugin.py b/xonsh/pytest/plugin.py index 927ea0f74..4cc5dc51d 100644 --- a/xonsh/pytest/plugin.py +++ b/xonsh/pytest/plugin.py @@ -22,6 +22,7 @@ from xonsh.execer import Execer from xonsh.jobs import tasks from xonsh.main import setup from xonsh.parsers.completion_context import CompletionContextParser + from .tools import DummyHistory, DummyShell, copy_env, sp diff --git a/xonsh/shell.py b/xonsh/shell.py index e0e1bee4e..503eb2e1c 100644 --- a/xonsh/shell.py +++ b/xonsh/shell.py @@ -14,7 +14,7 @@ from xonsh.platform import ( minimum_required_ptk_version, ptk_above_min_supported, ) -from xonsh.tools import XonshError, print_exception, simple_random_choice, is_class +from xonsh.tools import XonshError, is_class, print_exception, simple_random_choice events.doc( "on_transform_command", diff --git a/xonsh/xonfig.py b/xonsh/xonfig.py index 87d37ccec..4b1e2f68c 100644 --- a/xonsh/xonfig.py +++ b/xonsh/xonfig.py @@ -12,12 +12,11 @@ import shutil import textwrap import typing as tp -from xonsh.ply import ply - import xonsh.wizard as wiz from xonsh import __version__ as XONSH_VERSION from xonsh.built_ins import XSH from xonsh.cli_utils import Annotated, Arg, ArgParserAlias, add_args +from xonsh.events import events from xonsh.foreign_shells import CANON_SHELL_NAMES from xonsh.lazyasd import lazyobject from xonsh.platform import ( @@ -37,6 +36,7 @@ from xonsh.platform import ( ptk_version, pygments_version, ) +from xonsh.ply import ply from xonsh.prompt.base import is_template_string from xonsh.tools import ( color_style, @@ -49,7 +49,6 @@ from xonsh.tools import ( ) from xonsh.xontribs import find_xontrib, xontribs_loaded from xonsh.xontribs_meta import Xontrib, get_xontribs -from xonsh.events import events HR = "'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'" WIZARD_HEAD = """