diff --git a/pyproject.toml b/pyproject.toml index d8fb26d50..d6c9a91d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ readme = {file = ["README.rst"]} [tool.setuptools] packages = [ "xonsh", + "xonsh.api", "xonsh.shells", "xonsh.shells.ptk_shell", "xonsh.parsers.ply", @@ -243,9 +244,9 @@ convention = "numpy" "xonsh/style_tools.py" = ["F821"] "xonsh/xoreutils/*.py" = ["E722"] "xonsh/completers/python.py" = ["E722"] +"xonsh/parsers/ast.py" = ["F401"] "xonsh/shells/ptk_shell/__init__.py" = ["E731"] "xonsh/shells/readline_shell.py" = ["F401"] -"xonsh/parsers/ast.py" = ["F401"] "xonsh/commands_cache.py" = ["F841"] "xonsh/shells/ptk_shell/key_bindings.py" = ["F841"] "xonsh/tools.py" = [ @@ -256,7 +257,7 @@ convention = "numpy" "xonsh/inspectors.py" = ["E722"] "xonsh/platform.py" = ["F401"] "xonsh/parsers/*.py" = [ - "E741", # E741 Ambiguous variable name + "E741", # E741 Ambiguous variable name ] "tests/test*.py" = [ "E741", # E741 Ambiguous variable name diff --git a/tests/test_lib/test_os.xsh b/tests/api/test_os.xsh similarity index 96% rename from tests/test_lib/test_os.xsh rename to tests/api/test_os.xsh index eec425a62..51354d1a9 100644 --- a/tests/test_lib/test_os.xsh +++ b/tests/api/test_os.xsh @@ -1,7 +1,7 @@ import os import tempfile -from xonsh.lib.os import indir, rmtree +from xonsh.api.os import indir, rmtree import pytest diff --git a/tests/test_lib/test_subprocess.xsh b/tests/api/test_subprocess.xsh similarity index 94% rename from tests/test_lib/test_subprocess.xsh rename to tests/api/test_subprocess.xsh index aa099c6b3..96f372605 100644 --- a/tests/test_lib/test_subprocess.xsh +++ b/tests/api/test_subprocess.xsh @@ -2,8 +2,8 @@ import tempfile from subprocess import CalledProcessError -from xonsh.lib.os import indir -from xonsh.lib.subprocess import run, check_call, check_output +from xonsh.api.os import indir +from xonsh.api.subprocess import run, check_call, check_output import pytest diff --git a/tests/test_lib/test_collections.py b/tests/lib/test_collections.py similarity index 100% rename from tests/test_lib/test_collections.py rename to tests/lib/test_collections.py diff --git a/tests/test_lib/test_itertools.py b/tests/lib/test_itertools.py similarity index 100% rename from tests/test_lib/test_itertools.py rename to tests/lib/test_itertools.py diff --git a/tests/test_integrations.py b/tests/test_integrations.py index b3b033564..dad6860e1 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -462,7 +462,7 @@ def _echo(args): print(' '.join(args)) aliases['echo'] = _echo -from xonsh.lib.subprocess import check_output +from xonsh.api.subprocess import check_output print(check_output(["echo", "hello"]).decode("utf8")) """, diff --git a/xonsh/api/__init__.py b/xonsh/api/__init__.py new file mode 100644 index 000000000..26083fe66 --- /dev/null +++ b/xonsh/api/__init__.py @@ -0,0 +1,8 @@ +""" +Originally posted in https://github.com/xonsh/xonsh/issues/2726#issuecomment-406447196 : + Recently @CJ-Wright has started up a ``xonsh.lib`` (``xonsh.api``) sub-package, which is usable from pure Python. + This is meant as a standard library for xonsh and downstream tools. + Currently there are some xonsh-ish wrappers around ``os`` and ``subprocess``. + We'd love to see more contributions to this effort! So if there is something + like ``sh()`` that you'd like to see, by all means please help us add it! +""" diff --git a/xonsh/lib/os.py b/xonsh/api/os.py similarity index 100% rename from xonsh/lib/os.py rename to xonsh/api/os.py diff --git a/xonsh/lib/subprocess.py b/xonsh/api/subprocess.py similarity index 97% rename from xonsh/lib/subprocess.py rename to xonsh/api/subprocess.py index a557fa11a..4c6bd32a3 100644 --- a/xonsh/lib/subprocess.py +++ b/xonsh/api/subprocess.py @@ -1,8 +1,8 @@ """Xonsh extension of the standard library subprocess module, using xonsh for subprocess calls""" +from xonsh.api.os import indir from xonsh.built_ins import XSH, subproc_captured_hiddenobject, subproc_captured_stdout -from xonsh.lib.os import indir def run(cmd, cwd=None, check=False): diff --git a/xonsh/lib/__init__.py b/xonsh/lib/__init__.py index 327fb4ced..9d378eb6a 100644 --- a/xonsh/lib/__init__.py +++ b/xonsh/lib/__init__.py @@ -1,9 +1 @@ -""" -Originally posted by @scopatz in https://github.com/xonsh/xonsh/issues/2726#issuecomment-406447196 : - - Recently @CJ-Wright has started up a ``xonsh.lib`` sub-package, which is usable from pure Python. - This is meant as a standard library for xonsh and downstream tools. - Currently there are some xonsh-ish wrappers around ``os`` and ``subprocess``. - We'd love to see more contributions to this effort! So if there is something - like ``sh()`` that you'd like to see, by all means please help us add it! -""" +"""Libraries of common functions that used in xonsh components as well as modules borrowed from other projects.""" diff --git a/xonsh/parsers/ast.py b/xonsh/parsers/ast.py index 746e93845..bd5833737 100644 --- a/xonsh/parsers/ast.py +++ b/xonsh/parsers/ast.py @@ -4,10 +4,8 @@ # pylint: disable=unused-import import itertools import sys - -# pylint: disable=unused-import import textwrap -from ast import ( +from ast import ( # noqa # pylint: disable=unused-import AST, Add, And,