style: isort imports

fix #4584
This commit is contained in:
Noortheen Raja 2022-01-31 21:26:34 +05:30 committed by Gil Forsyth
parent 8007561fb5
commit 78091a22f3
158 changed files with 951 additions and 1001 deletions

View file

@ -1,10 +1,11 @@
import os.path
import pytest
import builtins
import os.path
from contextlib import contextmanager
from unittest.mock import MagicMock
from xonsh.aliases import source_alias, make_default_aliases
import pytest
from xonsh.aliases import make_default_aliases, source_alias
@pytest.fixture

View file

@ -1,4 +1,5 @@
import os
import pytest
from xonsh.aliases import xexec

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import sys
with open(sys.argv[-1]) as f:
for line in f:
print(line, end='')

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3
import os
x = os.getcwd()
print(x)

View file

@ -2,10 +2,7 @@ import pytest
from tests.tools import ON_WINDOWS
from xonsh.completers.base import complete_base
from xonsh.parsers.completion_context import (
CompletionContext,
CommandContext,
)
from xonsh.parsers.completion_context import CommandContext, CompletionContext
CUR_DIR = (
"." if ON_WINDOWS else "./"

View file

@ -1,13 +1,12 @@
import pytest
from tests.tools import skip_if_on_windows, skip_if_on_darwin
from xonsh.completers.tools import RichCompletion
from tests.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 (
CompletionContext,
CommandContext,
CommandArg,
CommandContext,
CompletionContext,
)

View file

@ -2,16 +2,14 @@ from unittest.mock import Mock
import pytest
from xonsh.parsers.completion_context import (
CompletionContext,
CommandArg,
CommandContext,
)
from tests.tools import ON_WINDOWS, skip_if_on_windows, completions_from_result
from tests.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 (
CommandArg,
CommandContext,
CompletionContext,
)
@pytest.fixture(autouse=True)

View file

@ -1,7 +1,7 @@
import pytest
from xonsh.parsers.completion_context import CompletionContextParser
from xonsh.completers.environment import complete_environment_vars
from xonsh.parsers.completion_context import CompletionContextParser
@pytest.fixture(scope="session")

View file

@ -5,7 +5,6 @@ import pytest
from xonsh.completers.commands import complete_xompletions
regex_cases = [
"pip",
"pip.exe",

View file

@ -6,17 +6,16 @@ from unittest.mock import MagicMock
import pytest
from tools import DummyHistory, DummyShell, copy_env, sp
from xonsh import commands_cache
from xonsh.aliases import Aliases
from xonsh.built_ins import XonshSession, XSH
from xonsh.built_ins import XSH, XonshSession
from xonsh.completer import Completer
from xonsh.events import events
from xonsh.execer import Execer
from xonsh.jobs import tasks
from xonsh.events import events
from xonsh.parsers.completion_context import CompletionContextParser
from xonsh import commands_cache
from tools import DummyShell, sp, DummyHistory, copy_env
@pytest.fixture
def source_path():
@ -293,6 +292,7 @@ def check_completer(completer_obj):
def ptk_shell(xonsh_execer):
from prompt_toolkit.input import create_pipe_input
from prompt_toolkit.output import DummyOutput
from xonsh.ptk_shell.shell import PromptToolkitShell
inp = create_pipe_input()

View file

@ -5,11 +5,10 @@ from subprocess import Popen
import pytest
from xonsh.procs.specs import cmds_to_specs, run_subproc
from xonsh.procs.posix import PopenThread
from xonsh.procs.proxies import ProcProxy, ProcProxyThread, STDOUT_DISPATCHER
from tests.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
@skip_if_on_windows

View file

@ -2,7 +2,7 @@ from unittest.mock import Mock
import pytest
from xonsh.prompt.base import PromptFormatter, PROMPT_FIELDS
from xonsh.prompt.base import PROMPT_FIELDS, PromptFormatter
@pytest.fixture

View file

@ -1,13 +1,12 @@
"""Testing built_ins.Aliases"""
import inspect
import os
import pytest
import inspect
from xonsh.aliases import Aliases, ExecAlias
from tools import skip_if_on_windows
from xonsh.aliases import Aliases, ExecAlias
def cd(args, stdin=None, **kwargs):

View file

@ -3,14 +3,13 @@ import pytest
from xonsh.ansi_colors import (
ansi_color_escape_code_to_name,
ansi_reverse_style,
ansi_color_name_to_escape_code,
ansi_color_style_names,
ansi_reverse_style,
ansi_style_by_name,
register_custom_ansi_style,
)
DEFAULT_CMAP = {
# Reset
"RESET": "0", # Text Reset

View file

@ -1,12 +1,11 @@
"""Xonsh AST tests."""
import ast as pyast
from xonsh import ast
from xonsh.ast import Tuple, Name, Store, min_line, Call, BinOp, isexpression
import pytest
from tools import nodes_equal
from xonsh import ast
from xonsh.ast import BinOp, Call, Name, Store, Tuple, isexpression, min_line
@pytest.fixture(autouse=True)

View file

@ -1,7 +1,8 @@
"""Tests bashisms xontrib."""
import pytest
import sys
import pytest
@pytest.fixture(name="bash_preproc", scope="module")
def _bash_preproc():

View file

@ -2,30 +2,28 @@
import os
import re
import types
from ast import AST, Module, Interactive, Expression
from ast import AST, Expression, Interactive, Module
import pytest
from tools import skip_if_on_windows
from xonsh.built_ins import (
reglob,
pathsearch,
helper,
superhelper,
ensure_list_of_strs,
list_of_strs_or_callables,
list_of_list_of_strs_outer_product,
regexsearch,
expand_path,
convert_macro_arg,
in_macro_call,
call_macro,
convert_macro_arg,
ensure_list_of_strs,
enter_macro,
expand_path,
helper,
in_macro_call,
list_of_list_of_strs_outer_product,
list_of_strs_or_callables,
pathsearch,
regexsearch,
reglob,
superhelper,
)
from xonsh.environ import Env
from tools import skip_if_on_windows
HOME_PATH = os.path.expanduser("~")

View file

@ -5,14 +5,14 @@ from unittest.mock import MagicMock
import pytest
from xonsh.commands_cache import (
CommandsCache,
predict_shell,
SHELL_PREDICTOR_PARSER,
predict_true,
predict_false,
)
from tools import skip_if_on_windows
from xonsh.commands_cache import (
SHELL_PREDICTOR_PARSER,
CommandsCache,
predict_false,
predict_shell,
predict_true,
)
def test_commands_cache_lazy(xession):

View file

@ -1,13 +1,13 @@
"""Tests for the base completer's logic (xonsh/completer.py)"""
import pytest
from xonsh.completer import Completer
from xonsh.completers.tools import (
RichCompletion,
contextual_command_completer,
non_exclusive_completer,
)
from xonsh.completer import Completer
from xonsh.parsers.completion_context import CommandContext

View file

@ -1,8 +1,11 @@
import itertools
import typing as tp
from unittest import mock
import pytest
from unittest import mock
import xonsh.parsers.completion_context as ctx
from tests.tools import ON_WINDOWS
from xonsh.parsers.completion_context import (
CommandArg,
CommandContext,
@ -10,10 +13,6 @@ from xonsh.parsers.completion_context import (
PythonContext,
)
import xonsh.parsers.completion_context as ctx
from tests.tools import ON_WINDOWS
DEBUG = False
MISSING = object()
X = "\x00" # cursor marker

View file

@ -3,7 +3,6 @@ from textwrap import dedent
from xonsh.contexts import Block, Functor
#
# helpers
#

View file

@ -1,13 +1,12 @@
"""Testing dirstack"""
from contextlib import contextmanager
import os
from contextlib import contextmanager
import pytest # noqa F401
from xonsh import dirstack
HERE = os.path.abspath(os.path.dirname(__file__))
PARENT = os.path.dirname(HERE)

View file

@ -7,10 +7,10 @@ import subprocess
import sys
import pytest
from xonsh import dirstack
from xonsh.dirstack import DIRSTACK
from xonsh.dirstack import DIRSTACK, _unc_tempDrives
from xonsh.platform import ON_WINDOWS
from xonsh.dirstack import _unc_tempDrives
HERE = os.path.abspath(os.path.dirname(__file__))
PARENT = os.path.dirname(HERE)

View file

@ -1,8 +1,8 @@
"""Tests the xonsh environment."""
import os
import re
import pathlib
import datetime
import os
import pathlib
import re
from random import shuffle
from tempfile import TemporaryDirectory
from threading import Thread
@ -10,19 +10,18 @@ from time import sleep
import pytest
from xonsh.tools import always_true, DefaultNotGiven
from tools import skip_if_on_unix
from xonsh.environ import (
Env,
locate_binary,
default_env,
make_args_env,
LsColors,
default_value,
Var,
InternalEnvironDict,
LsColors,
Var,
default_env,
default_value,
locate_binary,
make_args_env,
)
from tools import skip_if_on_unix
from xonsh.tools import DefaultNotGiven, always_true
def test_env_normal():

View file

@ -1,7 +1,9 @@
"""Event tests"""
import inspect
import pytest
from xonsh.events import EventManager, Event, LoadEvent
from xonsh.events import Event, EventManager, LoadEvent
@pytest.fixture

View file

@ -1,10 +1,10 @@
"""Tests the xonsh lexer."""
import os
from tools import skip_if_on_unix, skip_if_on_windows, ON_WINDOWS
import pytest
from tools import ON_WINDOWS, skip_if_on_unix, skip_if_on_windows
@pytest.fixture
def check_eval(xonsh_execer, xonsh_session, monkeypatch):

View file

@ -3,9 +3,9 @@ import os
import subprocess
import pytest # noqa F401
from tools import skip_if_on_windows, skip_if_on_unix
from xonsh.foreign_shells import foreign_shell_data, parse_env, parse_aliases
from tools import skip_if_on_unix, skip_if_on_windows
from xonsh.foreign_shells import foreign_shell_data, parse_aliases, parse_env
def test_parse_env():

View file

@ -7,12 +7,12 @@ import pytest
from xonsh.history.json import (
JsonHistory,
_xhj_gc_bytes_to_rmfiles,
_xhj_gc_commands_to_rmfiles,
_xhj_gc_files_to_rmfiles,
_xhj_gc_seconds_to_rmfiles,
_xhj_gc_bytes_to_rmfiles,
)
from xonsh.history.main import history_main, HistoryAlias
from xonsh.history.main import HistoryAlias, history_main
from xonsh.lazyjson import LazyJSON
CMDS = ["ls", "cat hello kitty", "abc", "def", "touch me", "grep from me"]
@ -372,9 +372,8 @@ def test_history_getitem(index, exp, hist, xession):
assert (entry.cmd, entry.out, entry.rtn, entry.ts) == exp
import time
import calendar
import time
HF_FIRST_DAY = calendar.timegm(time.struct_time((2018, 5, 13, 0, 0, 0, 0, 0, 0)))

View file

@ -3,11 +3,11 @@
import os
import shlex
from xonsh.history.sqlite import SqliteHistory
from xonsh.history.main import history_main
import pytest
from xonsh.history.main import history_main
from xonsh.history.sqlite import SqliteHistory
@pytest.fixture
def hist():

View file

@ -3,25 +3,23 @@ This requires Xonsh installed in venv or otherwise available on PATH
"""
import os
import shutil
import tempfile
import subprocess as sp
import tempfile
from pathlib import Path
import pytest
import xonsh
from xonsh.dirstack import with_pushd
from tools import (
ON_DARWIN,
ON_TRAVIS,
ON_WINDOWS,
skip_if_on_darwin,
skip_if_on_msys,
skip_if_on_unix,
skip_if_on_windows,
skip_if_on_darwin,
ON_WINDOWS,
ON_DARWIN,
ON_TRAVIS,
)
from xonsh.dirstack import with_pushd
PATH = (
os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin")

View file

@ -1,4 +1,5 @@
import pytest
from xonsh import jobs

View file

@ -3,8 +3,8 @@ import json
import pytest
from xonsh.tools import EnvPath
from xonsh.jsonutils import serialize_xonsh_json
from xonsh.tools import EnvPath
@pytest.mark.parametrize(

View file

@ -1,11 +1,12 @@
import sys
import pytest
from inspect import signature
from unittest.mock import MagicMock
import pytest
from tests.test_ptk_completer import EXPANSION_CASES
from xonsh.aliases import Aliases
from xonsh.completer import Completer
from tests.test_ptk_completer import EXPANSION_CASES
XonshKernel = None

View file

@ -1,7 +1,7 @@
"""Tests lazy json functionality."""
from io import StringIO
from xonsh.lazyjson import index, ljdump, LazyJSON, LJNode
from xonsh.lazyjson import LazyJSON, LJNode, index, ljdump
def test_index_int():

View file

@ -8,10 +8,8 @@ from pprint import pformat
import pytest
from xonsh.ply.ply.lex import LexToken
from xonsh.lexer import Lexer
from xonsh.ply.ply.lex import LexToken
LEXER_ARGS = {"lextab": "lexer_test_table", "debug": 0}

View file

@ -1,16 +1,16 @@
"""Tests the xonsh main function."""
from contextlib import contextmanager
import builtins
import gc
import os
import os.path
import sys
from contextlib import contextmanager
import pytest
import xonsh.main
from xonsh.main import XonshMode
import pytest
from tools import ON_WINDOWS, TEST_DIR, skip_if_on_windows
from xonsh.main import XonshMode
def Shell(*args, **kwargs):

View file

@ -3,7 +3,7 @@ import subprocess
import pytest # noqa F401
from tools import skip_if_on_windows, skip_if_not_on_darwin
from tools import skip_if_not_on_darwin, skip_if_on_windows
from xonsh.completers.man import complete_from_man

View file

@ -4,7 +4,6 @@ import re
import pytest
NEWSDIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "news")
CATEGORIES = frozenset(

View file

@ -1,16 +1,15 @@
"""Tests the xonsh parser."""
import ast
import textwrap
import itertools
import textwrap
import pytest
from xonsh.ast import AST, With, Pass, Str, Call
from tools import VER_MAJOR_MINOR, nodes_equal, skip_if_pre_3_8
from xonsh.ast import AST, Call, Pass, Str, With
from xonsh.parser import Parser
from xonsh.parsers.fstring_adaptor import FStringAdaptor
from tools import nodes_equal, skip_if_pre_3_8, VER_MAJOR_MINOR
@pytest.fixture
def xsh(xession, monkeypatch, parser):

View file

@ -1,6 +1,8 @@
import pytest
from unittest.mock import patch
import tempfile
from unittest.mock import patch
import pytest
import xonsh.completers.path as xcp

View file

@ -3,11 +3,12 @@ Tests for command pipelines.
"""
import os
import pytest
from tests.tools import skip_if_on_unix, skip_if_on_windows
from xonsh.platform import ON_WINDOWS
from xonsh.procs.pipelines import CommandPipeline
from tests.tools import skip_if_on_windows, skip_if_on_unix
@pytest.fixture(autouse=True)

View file

@ -1,7 +1,7 @@
import builtins
from contextlib import contextmanager
from unittest.mock import MagicMock
import builtins
import xonsh.platform as xp

View file

@ -1,7 +1,8 @@
from xonsh import pretty
import re
import pytest
from xonsh import pretty
long_list = ["str"] * 30
long_list_exp = "[" + (",\n ".join(["'str'"] * 30) + "]")

View file

@ -1,8 +1,9 @@
import pytest
from inspect import signature
from unittest.mock import MagicMock
from prompt_toolkit.document import Document
import pytest
from prompt_toolkit.completion import Completion as PTKCompletion
from prompt_toolkit.document import Document
from xonsh.aliases import Aliases
from xonsh.completer import Completer

View file

@ -3,22 +3,21 @@
import pytest
from pygments.token import (
Keyword,
Name,
String,
Error,
Keyword,
Literal,
Name,
Number,
Operator,
Punctuation,
String,
Text,
Literal,
)
from tools import skip_if_on_windows
from xonsh.pyghooks import XonshLexer, Color, XonshStyle, on_lscolors_change
from tools import DummyShell, skip_if_on_windows
from xonsh.environ import LsColors
from xonsh.events import events, EventManager
from tools import DummyShell
from xonsh.events import EventManager, events
from xonsh.pyghooks import Color, XonshLexer, XonshStyle, on_lscolors_change
@pytest.fixture

View file

@ -4,8 +4,8 @@ from unittest.mock import MagicMock, patch
import pytest
from prompt_toolkit.application import Application
from prompt_toolkit.document import Document
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.document import Document
from xonsh.tools import ON_WINDOWS

View file

@ -1,15 +1,16 @@
"""Test initialization of prompt_toolkit shell"""
import sys
import pytest
from xonsh.platform import minimum_required_ptk_version
import pyte
import pytest
# verify error if ptk not installed or below min
from tests.tools import ON_WINDOWS
from xonsh.platform import minimum_required_ptk_version
from xonsh.ptk_shell.shell import tokenize_ansi
from xonsh.shell import Shell
from tests.tools import ON_WINDOWS
# verify error if ptk not installed or below min
@pytest.mark.parametrize(

View file

@ -1,26 +1,25 @@
"""Tests pygments hooks."""
import pytest
import os
import stat
import pathlib
import stat
from tempfile import TemporaryDirectory
from xonsh.platform import ON_WINDOWS
import pytest
from xonsh.environ import LsColors
from xonsh.platform import ON_WINDOWS
from xonsh.pyghooks import (
XonshStyle,
Color,
Token,
color_name_to_pygments_code,
XonshStyle,
code_by_name,
color_file,
color_name_to_pygments_code,
file_color_tokens,
get_style_by_name,
register_custom_pygments_style,
)
from xonsh.environ import LsColors
@pytest.fixture
def xs_LS_COLORS(xession, os_env, monkeypatch):

View file

@ -1,11 +1,8 @@
import pytest
from tests.tools import skip_if_pre_3_8
from xonsh.completers.python import (
python_signature_complete,
complete_python,
)
from xonsh.completers.imports import complete_import
from xonsh.completers.python import complete_python, python_signature_complete
from xonsh.parsers.completion_context import (
CommandArg,
CommandContext,

View file

@ -1,10 +1,10 @@
"""Testing for ``xonsh.shell.Shell``"""
import os
from xonsh.shell import Shell
from xonsh.history.dummy import DummyHistory
from xonsh.history.json import JsonHistory
from xonsh.history.sqlite import SqliteHistory
from xonsh.history.dummy import DummyHistory
from xonsh.shell import Shell
def test_shell_with_json_history(xession, xonsh_execer, tmpdir_factory):

View file

@ -3,96 +3,91 @@ import datetime as dt
import os
import pathlib
import stat
from tempfile import TemporaryDirectory
import warnings
from tempfile import TemporaryDirectory
import pytest
from tools import skip_if_on_windows
from xonsh import __version__
from xonsh.platform import (
ON_WINDOWS,
HAS_PYGMENTS,
)
from xonsh.lexer import Lexer
from xonsh.platform import HAS_PYGMENTS, ON_WINDOWS
from xonsh.tools import (
EnvPath,
all_permutations,
always_false,
always_true,
argvquote,
balanced_parens,
bool_or_int_to_str,
bool_or_none_to_str,
bool_to_str,
check_for_partial_string,
check_quotes,
deprecated,
dynamic_cwd_tuple_to_str,
ends_with_colon_token,
ensure_slice,
ensure_string,
path_to_str,
ensure_timestamp,
env_path_to_str,
escape_windows_cmd_string,
executables_in,
expand_case_matching,
expand_path,
expandvars,
find_next_break,
get_line_continuation,
get_logical_line,
get_portions,
iglobpath,
is_balanced,
is_bool,
is_bool_or_int,
is_bool_or_none,
is_callable,
is_completion_mode,
is_completions_display_value,
is_dynamic_cwd_width,
is_path,
is_env_path,
is_float,
is_int,
is_int_as_str,
is_logfile_opt,
is_string_or_callable,
logfile_opt_to_str,
str_to_path,
str_to_env_path,
is_nonstring_seq_of_strings,
is_path,
is_slice_as_str,
is_string,
is_string_or_callable,
is_string_seq,
is_writable_file,
logfile_opt_to_str,
path_to_str,
pathsep_to_seq,
pathsep_to_set,
pathsep_to_upper_seq,
register_custom_style,
replace_logical_line,
seq_to_pathsep,
seq_to_upper_pathsep,
set_to_pathsep,
simple_random_choice,
str_to_env_path,
str_to_path,
subexpr_before_unbalanced,
subexpr_from_unbalanced,
subproc_toks,
swap_values,
to_bool,
to_bool_or_int,
to_bool_or_none,
to_int_or_none,
to_dynamic_cwd_tuple,
to_logfile_opt,
pathsep_to_set,
set_to_pathsep,
is_string_seq,
pathsep_to_seq,
seq_to_pathsep,
is_nonstring_seq_of_strings,
pathsep_to_upper_seq,
seq_to_upper_pathsep,
is_int_as_str,
is_slice_as_str,
ensure_timestamp,
get_portions,
is_balanced,
subexpr_before_unbalanced,
swap_values,
get_line_continuation,
get_logical_line,
replace_logical_line,
check_quotes,
deprecated,
is_writable_file,
balanced_parens,
ends_with_colon_token,
iglobpath,
all_permutations,
register_custom_style,
simple_random_choice,
is_completion_mode,
to_completion_mode,
is_completions_display_value,
to_completions_display_value,
expand_case_matching,
expandvars,
to_dynamic_cwd_tuple,
to_int_or_none,
to_logfile_opt,
)
from tools import skip_if_on_windows
LEXER = Lexer()
LEXER.build()

View file

@ -1,17 +1,17 @@
"""Vox tests"""
import os
import pathlib
import stat
import os
import subprocess as sp
import sys
import types
from typing import TYPE_CHECKING
import pytest
import sys
from xontrib.voxapi import Vox
from tools import skip_if_on_conda, skip_if_on_msys
from xonsh.platform import ON_WINDOWS
from typing import TYPE_CHECKING
from xontrib.voxapi import Vox
if TYPE_CHECKING:
from xontrib.vox import VoxHandler
@ -223,7 +223,7 @@ def test_autovox(xession, tmpdir, vox, a_venv, load_xontrib, registered):
"""
Tests that autovox works
"""
from xonsh.dirstack import pushd, popd
from xonsh.dirstack import popd, pushd
# Makes sure that event handlers are registered
load_xontrib("autovox")
@ -256,7 +256,7 @@ def venv_home(tmpdir):
@pytest.fixture
def venvs(venv_home):
"""Create virtualenv with names venv0, venv1"""
from xonsh.dirstack import pushd, popd
from xonsh.dirstack import popd, pushd
pushd([str(venv_home)])
paths = []

View file

@ -4,16 +4,15 @@ import os
import pytest # noqa F401
from xonsh.wizard import (
Wizard,
FileInserter,
Message,
Pass,
PrettyFormatter,
Message,
Question,
StateVisitor,
FileInserter,
Wizard,
)
TREE0 = Wizard(children=[Pass(), Message(message="yo")])
TREE1 = Question("wakka?", {"jawaka": Pass()})

View file

@ -5,15 +5,17 @@
- xonfig jupyter_kernel
"""
import io
import json
import os
import re
import sys
import json
import pytest # noqa F401
import io
from xonsh.tools import ON_WINDOWS
from xonsh.xonfig import xonfig_main
from xonsh.webconfig import main as web_main
from xonsh.xonfig import xonfig_main
def test_xonfg_help(capsys, xession):

View file

@ -1,6 +1,8 @@
"""xontrib tests, such as they are"""
import sys
import pytest
from xonsh.xontribs import xontrib_context, xontribs_load, xontribs_loaded

View file

@ -1,11 +1,11 @@
"""Tests the xonsh lexer."""
import ast
import copy
import os
import shutil
import sys
import ast
import platform
import shutil
import subprocess
import sys
import threading
from collections import defaultdict
@ -13,7 +13,6 @@ import pytest
from xonsh.base_shell import BaseShell
VER_MAJOR_MINOR = sys.version_info[:2]
VER_FULL = sys.version_info[:3]
ON_DARWIN = platform.system() == "Darwin"

View file

@ -5,6 +5,7 @@ import sys
from prompt_toolkit.buffer import Buffer
from pytest import fixture, mark
from xonsh.xontribs import find_xontrib

View file

@ -1,14 +1,14 @@
"""Tests for the Jedi completer xontrib"""
import sys
import pytest
import importlib
import sys
from unittest.mock import MagicMock, call
from tests.tools import skip_if_on_windows, skip_if_on_darwin
import pytest
from xonsh.xontribs import find_xontrib
from tests.tools import skip_if_on_darwin, skip_if_on_windows
from xonsh.completers.tools import RichCompletion
from xonsh.parsers.completion_context import CompletionContext, PythonContext
from xonsh.xontribs import find_xontrib
@pytest.fixture

View file

@ -1,5 +1,4 @@
from xonsh.cli_utils import ArgparseCompleter
from xonsh.parsers.completion_context import CommandContext

View file

@ -1,7 +1,6 @@
"""Completers for pip."""
from xonsh.completers.tools import comp_based_completer
from xonsh.parsers.completion_context import CommandContext

View file

@ -1,6 +1,6 @@
"""Completers for gh CLI"""
from xonsh.completers.tools import sub_proc_get_output, completion_from_cmd_output
from xonsh.completers.tools import completion_from_cmd_output, sub_proc_get_output
from xonsh.parsers.completion_context import CommandContext

View file

@ -1,51 +1,50 @@
"""Aliases for the xonsh shell."""
import argparse
import collections.abc as cabc
import functools
import inspect
import os
import re
import sys
import inspect
import argparse
import collections.abc as cabc
import types
import typing as tp
from xonsh.built_ins import XSH
from xonsh.lazyasd import lazyobject
from xonsh.dirstack import cd, pushd, popd, dirs, _get_cwd
from xonsh.environ import locate_binary, make_args_env
from xonsh.foreign_shells import foreign_shell_data
from xonsh.jobs import jobs, fg, bg, clean_jobs, disown
from xonsh.platform import (
ON_ANACONDA,
ON_DARWIN,
ON_WINDOWS,
ON_FREEBSD,
ON_NETBSD,
ON_OPENBSD,
ON_DRAGONFLY,
IN_APPIMAGE,
)
from xonsh.tools import (
XonshError,
argvquote,
escape_windows_cmd_string,
swap_values,
strip_simple_quotes,
ALIAS_KWARG_NAMES,
unthreadable,
print_color,
to_repr_pretty_,
to_shlvl,
adjust_shlvl,
)
from xonsh.timings import timeit_alias
from xonsh.xontribs import xontribs_main
from xonsh.ast import isexpression
from xonsh.cli_utils import ArgParserAlias, Arg, Annotated
import xonsh.completers._aliases as xca
import xonsh.history.main as xhm
import xonsh.xoreutils.which as xxw
from xonsh.ast import isexpression
from xonsh.built_ins import XSH
from xonsh.cli_utils import Annotated, Arg, ArgParserAlias
from xonsh.dirstack import _get_cwd, cd, dirs, popd, pushd
from xonsh.environ import locate_binary, make_args_env
from xonsh.foreign_shells import foreign_shell_data
from xonsh.jobs import bg, clean_jobs, disown, fg, jobs
from xonsh.lazyasd import lazyobject
from xonsh.platform import (
IN_APPIMAGE,
ON_ANACONDA,
ON_DARWIN,
ON_DRAGONFLY,
ON_FREEBSD,
ON_NETBSD,
ON_OPENBSD,
ON_WINDOWS,
)
from xonsh.timings import timeit_alias
from xonsh.tools import (
ALIAS_KWARG_NAMES,
XonshError,
adjust_shlvl,
argvquote,
escape_windows_cmd_string,
print_color,
strip_simple_quotes,
swap_values,
to_repr_pretty_,
to_shlvl,
unthreadable,
)
from xonsh.xontribs import xontribs_main
@lazyobject

View file

@ -4,22 +4,21 @@ import sys
import warnings
from xonsh.built_ins import XSH
from xonsh.platform import HAS_PYGMENTS
from xonsh.lazyasd import LazyDict, lazyobject
from xonsh.color_tools import (
RE_XONSH_COLOR,
BASE_XONSH_COLORS,
make_palette,
RE_XONSH_COLOR,
find_closest_color,
iscolor,
make_palette,
rgb2short,
rgb_to_256,
short_to_ints,
iscolor,
warn_deprecated_no_color,
)
from xonsh.lazyasd import LazyDict, lazyobject
from xonsh.platform import HAS_PYGMENTS
from xonsh.tools import FORMATTER
# pygments modifier to ANSI escape code mapping
_PART_STYLE_CODE_MAPPING = {
"bold": "1",
@ -1151,9 +1150,10 @@ def ansi_style_by_name(name):
return ANSI_STYLES[name]
elif not HAS_PYGMENTS:
raise KeyError(f"could not find style {name!r}")
from xonsh.pygments_cache import get_style_by_name
from pygments.util import ClassNotFound
from xonsh.pygments_cache import get_style_by_name
try:
pstyle = get_style_by_name(name)
except (ModuleNotFoundError, ClassNotFound):

View file

@ -1,127 +1,125 @@
"""Abstract Syntax Tree handler"""
# These are imported into our module namespace for the benefit of parser.py.
# pylint: disable=unused-import
import itertools
import sys
from ast import (
Module,
Num,
Expr,
Str,
Bytes,
UnaryOp,
UAdd,
USub,
Invert,
BinOp,
Add,
Sub,
Mult,
Div,
FloorDiv,
Mod,
Pow,
Compare,
Lt,
Gt,
LtE,
GtE,
Eq,
NotEq,
In,
NotIn,
Is,
IsNot,
Not,
BoolOp,
Or,
And,
Subscript,
Load,
Slice,
ExtSlice,
List,
Tuple,
Set,
Dict,
AST,
NameConstant,
Name,
GeneratorExp,
Store,
comprehension,
ListComp,
SetComp,
DictComp,
Assign,
AugAssign,
BitXor,
BitAnd,
BitOr,
LShift,
RShift,
Assert,
Delete,
Del,
Pass,
Raise,
Import,
alias,
ImportFrom,
Continue,
Break,
Yield,
YieldFrom,
Return,
IfExp,
Lambda,
arguments,
arg,
Call,
keyword,
Attribute,
Global,
Nonlocal,
If,
While,
For,
withitem,
With,
Try,
ExceptHandler,
FunctionDef,
ClassDef,
Starred,
NodeTransformer,
Interactive,
Expression,
Index,
literal_eval,
dump,
walk,
increment_lineno,
Constant,
)
from ast import Ellipsis as EllipsisNode
# pylint: enable=unused-import
import textwrap
import itertools
from xonsh.built_ins import XSH
from xonsh.tools import subproc_toks, find_next_break, get_logical_line
from ast import (
MatMult,
AST,
Add,
And,
AnnAssign,
Assert,
Assign,
AsyncFor,
AsyncFunctionDef,
AsyncWith,
AsyncFor,
Attribute,
AugAssign,
Await,
JoinedStr,
BinOp,
BitAnd,
BitOr,
BitXor,
BoolOp,
Break,
Bytes,
Call,
ClassDef,
Compare,
Constant,
Continue,
Del,
Delete,
Dict,
DictComp,
Div,
)
from ast import Ellipsis as EllipsisNode
from ast import (
Eq,
ExceptHandler,
Expr,
Expression,
ExtSlice,
FloorDiv,
For,
FormattedValue,
AnnAssign,
FunctionDef,
GeneratorExp,
Global,
Gt,
GtE,
If,
IfExp,
Import,
ImportFrom,
In,
Index,
Interactive,
Invert,
Is,
IsNot,
JoinedStr,
Lambda,
List,
ListComp,
Load,
LShift,
Lt,
LtE,
MatMult,
Mod,
Module,
Mult,
Name,
NameConstant,
NodeTransformer,
Nonlocal,
Not,
NotEq,
NotIn,
Num,
Or,
Pass,
Pow,
Raise,
Return,
RShift,
Set,
SetComp,
Slice,
Starred,
Store,
Str,
Sub,
Subscript,
Try,
Tuple,
UAdd,
UnaryOp,
USub,
While,
With,
Yield,
YieldFrom,
alias,
arg,
arguments,
comprehension,
dump,
increment_lineno,
keyword,
literal_eval,
walk,
withitem,
)
from xonsh.built_ins import XSH
from xonsh.platform import PYTHON_VERSION_INFO
from xonsh.tools import find_next_break, get_logical_line, subproc_toks
if PYTHON_VERSION_INFO > (3, 8):
from ast import NamedExpr # type:ignore

View file

@ -5,30 +5,30 @@ import sys
import time
from os.path import expanduser
from xonsh.ansi_colors import ansi_partial_color_format
from xonsh.built_ins import XSH
from xonsh.codecache import (
code_cache_check,
code_cache_name,
get_cache_filename,
run_compiled_code,
should_use_cache,
update_cache,
)
from xonsh.completer import Completer
from xonsh.events import events
from xonsh.lazyimps import pyghooks, pygments
from xonsh.platform import HAS_PYGMENTS, ON_WINDOWS
from xonsh.prompt.base import PromptFormatter, multiline_prompt
from xonsh.shell import transform_command
from xonsh.tools import (
XonshError,
print_exception,
DefaultNotGiven,
XonshError,
check_for_partial_string,
format_std_prepost,
get_line_continuation,
print_exception,
)
from xonsh.platform import HAS_PYGMENTS, ON_WINDOWS
from xonsh.codecache import (
should_use_cache,
code_cache_name,
code_cache_check,
get_cache_filename,
update_cache,
run_compiled_code,
)
from xonsh.completer import Completer
from xonsh.prompt.base import multiline_prompt, PromptFormatter
from xonsh.events import events
from xonsh.shell import transform_command
from xonsh.lazyimps import pygments, pyghooks
from xonsh.ansi_colors import ansi_partial_color_format
if ON_WINDOWS:
import ctypes

View file

@ -3,29 +3,29 @@
Note that this module is named 'built_ins' so as not to be confused with the
special Python builtins module.
"""
import atexit
import builtins
import collections.abc as cabc
import contextlib
import inspect
import itertools
import os
import pathlib
import re
import signal
import sys
import types
import signal
import atexit
import pathlib
import inspect
import warnings
import builtins
import itertools
import contextlib
import collections.abc as cabc
from ast import AST
from xonsh.lazyasd import lazyobject
from xonsh.inspectors import Inspector
from xonsh.lazyasd import lazyobject
from xonsh.platform import ON_POSIX, ON_WINDOWS
from xonsh.tools import (
XonshCalledProcessError,
XonshError,
expand_path,
globpath,
XonshError,
XonshCalledProcessError,
print_color,
)
@ -584,9 +584,9 @@ class XonshSession:
ctx : Mapping, optional
Context to start xonsh session with.
"""
from xonsh.environ import Env, default_env
from xonsh.commands_cache import CommandsCache
from xonsh.completers.init import default_completers
from xonsh.environ import Env, default_env
if not hasattr(builtins, "__xonsh__"):
builtins.__xonsh__ = self

View file

@ -301,7 +301,7 @@ class RstHelpFormatter(ap.RawTextHelpFormatter):
return text
def _format_usage(self, usage, actions, groups, prefix):
from pygments.token import Name, Generic
from pygments.token import Generic, Name
text = super()._format_usage(usage, actions, groups, prefix)
parts = text.split(self._prog, maxsplit=1)

View file

@ -5,10 +5,10 @@ color codes. Parts of this file were originally forked from Micah Elliott
http://MicahElliott.com Copyright (C) 2011 Micah Elliott. All rights reserved.
WTFPL http://sam.zoy.org/wtfpl/
"""
import re
import math
import re
from xonsh.lazyasd import lazyobject, LazyObject
from xonsh.lazyasd import LazyObject, lazyobject
from xonsh.tools import print_warning
_NO_COLOR_WARNING_SHOWN = False

View file

@ -5,21 +5,21 @@ A background predictor is a function that accepts a single argument list
and returns whether or not the process can be run in the background (returns
True) or must be run the foreground (returns False).
"""
import argparse
import collections.abc as cabc
import functools
import os
import pickle
import sys
import threading
import time
import argparse
import collections.abc as cabc
import typing as tp
from pathlib import Path
from xonsh.built_ins import XSH
from xonsh.platform import ON_WINDOWS, ON_POSIX, pathbasename
from xonsh.tools import executables_in
from xonsh.lazyasd import lazyobject
from xonsh.platform import ON_POSIX, ON_WINDOWS, pathbasename
from xonsh.tools import executables_in
class CommandsCache(cabc.Mapping):

View file

@ -1,17 +1,17 @@
"""A (tab-)completer for xonsh."""
import collections.abc as cabc
import sys
import typing as tp
import collections.abc as cabc
from xonsh.built_ins import XSH
from xonsh.completers.tools import (
is_contextual_completer,
Completion,
RichCompletion,
apply_lprefix,
is_exclusive_completer,
get_filter_function,
is_contextual_completer,
is_exclusive_completer,
)
from xonsh.built_ins import XSH
from xonsh.parsers.completion_context import CompletionContext, CompletionContextParser
from xonsh.tools import print_exception

View file

@ -1,9 +1,9 @@
import xonsh.cli_utils as xcli
from xonsh.built_ins import XSH
from xonsh.completers.completer import (
add_one_completer,
list_completers,
remove_completer,
add_one_completer,
)
from xonsh.completers.tools import contextual_command_completer
from xonsh.parsers.completion_context import CommandContext

View file

@ -1,14 +1,11 @@
"""Base completer for xonsh."""
import collections.abc as cabc
from xonsh.parsers.completion_context import CompletionContext
from xonsh.completers.tools import (
contextual_completer,
apply_lprefix,
)
from xonsh.completers.commands import complete_command
from xonsh.completers.path import contextual_complete_path
from xonsh.completers.python import complete_python
from xonsh.completers.commands import complete_command
from xonsh.completers.tools import apply_lprefix, contextual_completer
from xonsh.parsers.completion_context import CompletionContext
@contextual_completer

View file

@ -1,12 +1,12 @@
"""Xonsh hooks into bash completions."""
import xonsh.tools as xt
import xonsh.platform as xp
from xonsh.completers.path import _quote_paths
from xonsh.completers.bash_completion import bash_completions
from xonsh.completers.tools import contextual_command_completer, RichCompletion
from xonsh.parsers.completion_context import CommandContext
import xonsh.tools as xt
from xonsh.built_ins import XSH
from xonsh.completers.bash_completion import bash_completions
from xonsh.completers.path import _quote_paths
from xonsh.completers.tools import RichCompletion, contextual_command_completer
from xonsh.parsers.completion_context import CommandContext
@contextual_command_completer

View file

@ -1,18 +1,19 @@
"""This module provides the implementation for the retrieving completion results
from bash.
"""
import functools
# developer note: this file should not perform any action on import.
# This file comes from https://github.com/xonsh/py-bash-completion
# and should be edited there!
import os
import re
import sys
import shlex
import shutil
import pathlib
import platform
import functools
import re
import shlex
import shutil
import subprocess
import sys
import typing as tp
__version__ = "0.2.7"

View file

@ -7,19 +7,18 @@ import re
import typing as tp
from collections import OrderedDict
import xonsh.tools as xt
import xonsh.platform as xp
import xonsh.tools as xt
from xonsh.built_ins import XSH
from xonsh.completer import Completer
from xonsh.completers.tools import (
get_filter_function,
contextual_command_completer,
RichCompletion,
contextual_command_completer,
get_filter_function,
non_exclusive_completer,
)
from xonsh.parsers.completion_context import CompletionContext, CommandContext
from xonsh.built_ins import XSH
from xonsh.environ import scan_dir_for_source_files
from xonsh.parsers.completion_context import CommandContext, CompletionContext
SKIP_TOKENS = {"sudo", "time", "timeit", "which", "showcmd", "man"}
END_PROC_TOKENS = ("|", ";", "&&") # includes ||

View file

@ -1,12 +1,8 @@
import collections
from xonsh.built_ins import XSH
from xonsh.cli_utils import Arg, Annotated, NumpyDoc
from xonsh.completers.tools import (
justify,
is_exclusive_completer,
RichCompletion,
)
from xonsh.cli_utils import Annotated, Arg, NumpyDoc
from xonsh.completers.tools import RichCompletion, is_exclusive_completer, justify
def add_one_completer(name, func, loc="end"):

View file

@ -1,11 +1,11 @@
from xonsh.built_ins import XSH
from xonsh.parsers.completion_context import CompletionContext
from xonsh.completers.tools import (
contextual_completer,
non_exclusive_completer,
get_filter_function,
RichCompletion,
contextual_completer,
get_filter_function,
non_exclusive_completer,
)
from xonsh.parsers.completion_context import CompletionContext
@contextual_completer

View file

@ -6,23 +6,23 @@ Contains modified code from the IPython project (at core/completerlib.py).
# Distributed under the terms of the Modified BSD License.
"""
import inspect
import os
import re
import sys
import inspect
from time import time
import typing as tp
from importlib import import_module
from importlib.machinery import all_suffixes
from time import time
from zipimport import zipimporter
import typing as tp
from xonsh.built_ins import XSH
from xonsh.lazyasd import lazyobject
from xonsh.completers.tools import (
RichCompletion,
contextual_completer,
get_filter_function,
RichCompletion,
)
from xonsh.lazyasd import lazyobject
from xonsh.parsers.completion_context import CompletionContext
_suffixes = all_suffixes()

View file

@ -1,22 +1,20 @@
"""Constructor for xonsh completer objects."""
import collections
from xonsh.completers.man import complete_from_man
from xonsh.completers.bash import complete_from_bash
from xonsh.completers._aliases import complete_aliases
from xonsh.completers.base import complete_base
from xonsh.completers.path import complete_path
from xonsh.completers.python import (
complete_python,
)
from xonsh.completers.imports import complete_import
from xonsh.completers.bash import complete_from_bash
from xonsh.completers.commands import (
complete_skipper,
complete_end_proc_tokens,
complete_end_proc_keywords,
complete_end_proc_tokens,
complete_skipper,
complete_xompletions,
)
from xonsh.completers._aliases import complete_aliases
from xonsh.completers.environment import complete_environment_vars
from xonsh.completers.imports import complete_import
from xonsh.completers.man import complete_from_man
from xonsh.completers.path import complete_path
from xonsh.completers.python import complete_python
def default_completers(cmd_cache):

View file

@ -7,10 +7,7 @@ import textwrap
from pathlib import Path
from xonsh.built_ins import XSH
from xonsh.completers.tools import (
contextual_command_completer,
RichCompletion,
)
from xonsh.completers.tools import RichCompletion, contextual_command_completer
from xonsh.parsers.completion_context import CommandContext

View file

@ -1,19 +1,14 @@
import os
import re
import ast
import glob
import os
import re
from xonsh.built_ins import XSH
from xonsh.parsers.completion_context import CommandContext
import xonsh.tools as xt
import xonsh.platform as xp
import xonsh.lazyasd as xl
from xonsh.completers.tools import (
RichCompletion,
contextual_completer,
)
import xonsh.platform as xp
import xonsh.tools as xt
from xonsh.built_ins import XSH
from xonsh.completers.tools import RichCompletion, contextual_completer
from xonsh.parsers.completion_context import CommandContext
@xl.lazyobject

View file

@ -1,21 +1,20 @@
"""Completers for Python code"""
import re
import inspect
import builtins
import warnings
import collections.abc as cabc
from xonsh.parsers.completion_context import CompletionContext, PythonContext
import inspect
import re
import warnings
import xonsh.tools as xt
import xonsh.lazyasd as xl
import xonsh.tools as xt
from xonsh.built_ins import XSH
from xonsh.completers.tools import (
CompleterResult,
RichCompletion,
contextual_completer,
get_filter_function,
RichCompletion,
)
from xonsh.parsers.completion_context import CompletionContext, PythonContext
@xl.lazyobject

View file

@ -10,7 +10,7 @@ from functools import wraps
import xonsh.tools as xt
from xonsh.built_ins import XSH
from xonsh.lazyasd import lazyobject
from xonsh.parsers.completion_context import CompletionContext, CommandContext
from xonsh.parsers.completion_context import CommandContext, CompletionContext
def _filter_with_func(text, prefix, func):

View file

@ -1,11 +1,10 @@
"""Tools for diff'ing two xonsh history files in a meaningful fashion."""
import difflib
import datetime
import difflib
import itertools
from xonsh.lazyjson import LazyJSON
from xonsh.color_tools import COLORS
from xonsh.lazyjson import LazyJSON
# intern some strings
REPLACE_S = "replace"

View file

@ -1,104 +1,104 @@
"""Environment for the xonsh shell."""
import inspect
import os
import re
import sys
import pprint
import textwrap
import locale
import threading
import warnings
import contextlib
import collections.abc as cabc
import subprocess
import contextlib
import inspect
import locale
import os
import platform
import pprint
import re
import subprocess
import sys
import textwrap
import threading
import typing as tp
import warnings
from collections import ChainMap
import xonsh.prompt.base as prompt
from xonsh import __version__ as XONSH_VERSION
from xonsh.lazyasd import lazyobject, LazyBool
from xonsh.codecache import run_script_with_cache
from xonsh.dirstack import _get_cwd
from xonsh.events import events
from xonsh.platform import (
BASH_COMPLETIONS_DEFAULT,
DEFAULT_ENCODING,
PATH_DEFAULT,
ON_WINDOWS,
ON_LINUX,
ON_CYGWIN,
os_environ,
)
from xonsh.built_ins import XSH
from xonsh.tools import (
always_true,
always_false,
detype,
ensure_string,
is_path,
str_to_path,
path_to_str,
is_env_path,
str_to_env_path,
env_path_to_str,
is_bool,
to_bool,
bool_to_str,
is_bool_or_none,
to_bool_or_none,
bool_or_none_to_str,
is_history_tuple,
to_history_tuple,
history_tuple_to_str,
is_float,
is_string,
is_string_or_callable,
is_completions_display_value,
to_completions_display_value,
is_completion_mode,
to_completion_mode,
is_string_set,
csv_to_set,
set_to_csv,
is_int,
to_bool_or_int,
bool_or_int_to_str,
DefaultNotGiven,
print_exception,
intensify_colors_on_win_setter,
is_dynamic_cwd_width,
to_dynamic_cwd_tuple,
dynamic_cwd_tuple_to_str,
is_logfile_opt,
to_logfile_opt,
logfile_opt_to_str,
executables_in,
is_nonstring_seq_of_strings,
pathsep_to_upper_seq,
seq_to_upper_pathsep,
print_color,
is_history_backend,
to_itself,
swap_values,
ptk2_color_depth_setter,
is_str_str_dict,
to_str_str_dict,
dict_to_str,
to_int_or_none,
DefaultNotGivenType,
to_repr_pretty_,
to_shlvl,
is_valid_shlvl,
adjust_shlvl,
)
from xonsh.ansi_colors import (
ansi_color_escape_code_to_name,
ansi_color_name_to_escape_code,
ansi_reverse_style,
ansi_style_by_name,
)
import xonsh.prompt.base as prompt
from xonsh.built_ins import XSH
from xonsh.codecache import run_script_with_cache
from xonsh.dirstack import _get_cwd
from xonsh.events import events
from xonsh.lazyasd import LazyBool, lazyobject
from xonsh.platform import (
BASH_COMPLETIONS_DEFAULT,
DEFAULT_ENCODING,
ON_CYGWIN,
ON_LINUX,
ON_WINDOWS,
PATH_DEFAULT,
os_environ,
)
from xonsh.prompt.gitstatus import _DEFS as GITSTATUS_FIELD_DEFS
from xonsh.tools import (
DefaultNotGiven,
DefaultNotGivenType,
adjust_shlvl,
always_false,
always_true,
bool_or_int_to_str,
bool_or_none_to_str,
bool_to_str,
csv_to_set,
detype,
dict_to_str,
dynamic_cwd_tuple_to_str,
ensure_string,
env_path_to_str,
executables_in,
history_tuple_to_str,
intensify_colors_on_win_setter,
is_bool,
is_bool_or_none,
is_completion_mode,
is_completions_display_value,
is_dynamic_cwd_width,
is_env_path,
is_float,
is_history_backend,
is_history_tuple,
is_int,
is_logfile_opt,
is_nonstring_seq_of_strings,
is_path,
is_str_str_dict,
is_string,
is_string_or_callable,
is_string_set,
is_valid_shlvl,
logfile_opt_to_str,
path_to_str,
pathsep_to_upper_seq,
print_color,
print_exception,
ptk2_color_depth_setter,
seq_to_upper_pathsep,
set_to_csv,
str_to_env_path,
str_to_path,
swap_values,
to_bool,
to_bool_or_int,
to_bool_or_none,
to_completion_mode,
to_completions_display_value,
to_dynamic_cwd_tuple,
to_history_tuple,
to_int_or_none,
to_itself,
to_logfile_opt,
to_repr_pretty_,
to_shlvl,
to_str_str_dict,
)
events.doc(
"on_envvar_new",

View file

@ -1,20 +1,20 @@
"""Implements the xonsh executer."""
import sys
import types
import inspect
import builtins
import collections.abc as cabc
import inspect
import sys
import types
from xonsh.ast import CtxAwareTransformer
from xonsh.parser import Parser
from xonsh.tools import (
subproc_toks,
balanced_parens,
ends_with_colon_token,
find_next_break,
get_logical_line,
replace_logical_line,
balanced_parens,
starting_whitespace,
ends_with_colon_token,
subproc_toks,
)

View file

@ -1,19 +1,18 @@
"""Tools to help interface with foreign shells, such as Bash."""
import collections.abc as cabc
import functools
import os
import re
import shlex
import subprocess
import sys
import tempfile
import subprocess
import warnings
import functools
import collections.abc as cabc
from xonsh.built_ins import XSH
from xonsh.lazyasd import lazyobject
from xonsh.tools import to_bool, ensure_string
from xonsh.platform import ON_WINDOWS, ON_CYGWIN, ON_MSYS
from xonsh.platform import ON_CYGWIN, ON_MSYS, ON_WINDOWS
from xonsh.tools import ensure_string, to_bool
COMMAND = """{seterrprevcmd}
{prevcmd}

View file

@ -1,5 +1,6 @@
"""Implements the xonsh history backend."""
import collections
from xonsh.history.base import History

View file

@ -1,10 +1,10 @@
"""Implements JSON version of xonsh history backend."""
import collections
import collections.abc as cabc
import os
import sys
import time
import collections
import threading
import collections.abc as cabc
import time
from xonsh.built_ins import XSH
@ -13,10 +13,10 @@ try:
except ImportError:
import json # type: ignore
from xonsh.history.base import History
import xonsh.tools as xt
import xonsh.lazyjson as xlj
import xonsh.tools as xt
import xonsh.xoreutils.uptime as uptime
from xonsh.history.base import History
def _xhj_gc_commands_to_rmfiles(hsize, files):

View file

@ -6,14 +6,14 @@ import sys
import threading
import typing as tp
from xonsh.built_ins import XSH
import xonsh.cli_utils as xcli
import xonsh.diff_history as xdh
import xonsh.tools as xt
from xonsh.built_ins import XSH
from xonsh.history.base import History
from xonsh.history.dummy import DummyHistory
from xonsh.history.json import JsonHistory
from xonsh.history.sqlite import SqliteHistory
import xonsh.diff_history as xdh
import xonsh.tools as xt
HISTORY_BACKENDS = {"dummy": DummyHistory, "json": JsonHistory, "sqlite": SqliteHistory}

View file

@ -7,9 +7,9 @@ import sys
import threading
import time
import xonsh.tools as xt
from xonsh.built_ins import XSH
from xonsh.history.base import History
import xonsh.tools as xt
XH_SQLITE_CACHE = threading.local()
XH_SQLITE_TABLE_NAME = "xonsh_history"

View file

@ -8,15 +8,15 @@ import os
import re
import sys
import types
from importlib.abc import MetaPathFinder, SourceLoader, Loader
from importlib.abc import Loader, MetaPathFinder, SourceLoader
from importlib.machinery import ModuleSpec
from xonsh.built_ins import XSH
from xonsh.events import events
from xonsh.tools import print_warning
from xonsh.execer import Execer
from xonsh.lazyasd import lazyobject
from xonsh.platform import ON_WINDOWS
from xonsh.tools import print_warning
@lazyobject

View file

@ -7,21 +7,20 @@ This file was forked from the IPython project:
* Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
* Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
"""
import os
import sys
import types
import inspect
import itertools
import linecache
import os
import sys
import types
from xonsh.lazyasd import LazyObject
from xonsh.tokenize import detect_encoding
from xonsh.lazyimps import pyghooks, pygments
from xonsh.openpy import read_py_file
from xonsh.tools import cast_unicode, safe_hasattr, indent, print_color, format_color
from xonsh.platform import HAS_PYGMENTS
from xonsh.lazyimps import pygments, pyghooks
from xonsh.style_tools import partial_color_tokenize
from xonsh.tokenize import detect_encoding
from xonsh.tools import cast_unicode, format_color, indent, print_color, safe_hasattr
# builtin docstrings to ignore
_func_call_docstring = LazyObject(

View file

@ -1,18 +1,18 @@
"""Job control for the xonsh shell."""
import os
import sys
import time
import collections
import ctypes
import os
import signal
import subprocess
import collections
import sys
import time
import typing as tp
from xonsh.built_ins import XSH
from xonsh.cli_utils import Annotated, Arg, ArgParserAlias
from xonsh.completers.tools import RichCompletion
from xonsh.lazyasd import LazyObject
from xonsh.platform import FD_STDERR, ON_DARWIN, ON_WINDOWS, ON_CYGWIN, ON_MSYS, LIBC
from xonsh.platform import FD_STDERR, LIBC, ON_CYGWIN, ON_DARWIN, ON_MSYS, ON_WINDOWS
from xonsh.tools import unthreadable
# there is not much cost initing deque

View file

@ -1,25 +1,25 @@
"""Hooks for Jupyter Xonsh Kernel."""
import sys
import json
import hmac
import uuid
import datetime
import errno
import hashlib
import datetime
import hmac
import json
import sys
import threading
from pprint import pformat
import uuid
from argparse import ArgumentParser
from collections.abc import Set
from pprint import pformat
import zmq
from zmq.eventloop import ioloop, zmqstream
from zmq.error import ZMQError
from zmq.eventloop import ioloop, zmqstream
from xonsh import __version__ as version
from xonsh.built_ins import XSH
from xonsh.main import setup
from xonsh.completer import Completer
from xonsh.commands_cache import predict_true
from xonsh.completer import Completer
from xonsh.main import setup
MAX_SIZE = 8388608 # 8 Mb
DELIM = b"<IDS|MSG>"

View file

@ -1,14 +1,14 @@
"""Lazy and self destructive containers for speeding up module import."""
# Copyright 2015-2016, the xonsh developers. All rights reserved.
import os
import sys
import time
import types
import builtins
import threading
import collections.abc as cabc
import importlib
import importlib.util
import collections.abc as cabc
import os
import sys
import threading
import time
import types
import typing as tp
__version__ = "0.1.3"

View file

@ -1,9 +1,9 @@
"""Lazy imports that may apply across the xonsh package."""
import os
import importlib
import os
from xonsh.platform import ON_WINDOWS, ON_DARWIN
from xonsh.lazyasd import LazyObject, lazyobject
from xonsh.platform import ON_DARWIN, ON_WINDOWS
pygments = LazyObject(
lambda: importlib.import_module("pygments"), globals(), "pygments"

View file

@ -1,8 +1,8 @@
"""Implements a lazy JSON file class that wraps around json data."""
import collections.abc as cabc
import contextlib
import io
import weakref
import contextlib
import collections.abc as cabc
try:
import ujson as json

View file

@ -3,38 +3,37 @@
Written using a hybrid of ``tokenize`` and PLY.
"""
import io
import re
# 'keyword' interferes with ast.keyword
import keyword as kwmod
import re
import typing as tp
from xonsh.ply.ply.lex import LexToken
from xonsh.lazyasd import lazyobject
from xonsh.platform import PYTHON_VERSION_INFO
from xonsh.ply.ply.lex import LexToken
from xonsh.tokenize import (
OP,
IOREDIRECT,
STRING,
DOLLARNAME,
NUMBER,
SEARCHPATH,
NEWLINE,
INDENT,
DEDENT,
NL,
COMMENT,
DEDENT,
DOLLARNAME,
ENCODING,
ENDMARKER,
NAME,
ERRORTOKEN,
GREATER,
LESS,
RIGHTSHIFT,
tokenize,
TokenError,
HAS_WALRUS,
INDENT,
IOREDIRECT,
LESS,
NAME,
NEWLINE,
NL,
NUMBER,
OP,
RIGHTSHIFT,
SEARCHPATH,
STRING,
TokenError,
tokenize,
)

View file

@ -1,10 +1,9 @@
"""Base class for chaining DBs"""
import itertools
import typing as tp
from collections import ChainMap
from collections.abc import MutableMapping, MutableSequence, MutableSet
import typing as tp
class ChainDBDefaultType:

Some files were not shown because too many files have changed in this diff Show more