From 46af782db285c3c50e1fd93ad101d7ca5dd8db50 Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Tue, 18 Nov 2025 20:47:20 +0200 Subject: [PATCH] build: drop shtab wrapper after their release --- tox.toml | 14 ++++---------- toxfile.py | 39 --------------------------------------- 2 files changed, 4 insertions(+), 49 deletions(-) diff --git a/tox.toml b/tox.toml index dbe6f35f..390f5c84 100644 --- a/tox.toml +++ b/tox.toml @@ -140,8 +140,6 @@ dynamic_version = "{[project]name}.__version__" extras = [ { replace = "ref", of = ["project", "extras"], extend = true }, ] -# TODO: steamline shlex usage after https://github.com/iterative/shtab/pull/192 merge -handle_redirect = true pip_pre = true set_env.PYTHONPATH = "src" set_env.SPHINX_APIDOC_OPTIONS = "members,no-undoc-members,show-inheritance" @@ -149,18 +147,14 @@ commands = [ [ "shtab", { replace = "ref", of = ["flags", "shtab"], extend = true }, - "--shell", - "bash", - ">", - "package/share/bash-completion/completions/_ahriman", + "--shell", "bash", + "--output", "package/share/bash-completion/completions/_ahriman", ], [ "shtab", { replace = "ref", of = ["flags", "shtab"], extend = true }, - "--shell", - "zsh", - ">", - "package/share/zsh/site-functions/_ahriman", + "--shell", "zsh", + "--output", "package/share/zsh/site-functions/_ahriman", ], [ "argparse-manpage", diff --git a/toxfile.py b/toxfile.py index 02e9d69c..437d61a1 100644 --- a/toxfile.py +++ b/toxfile.py @@ -18,11 +18,9 @@ # along with this program. If not, see . # import importlib -import shlex import sys from tox.config.sets import EnvConfigSet -from tox.config.types import Command from tox.plugin import impl from tox.session.state import State from tox.tox_env.api import ToxEnv @@ -56,35 +54,6 @@ def _extract_version(env_conf: EnvConfigSet, python_path: str | None = None) -> return {"VERSION": version} -def _wrap_commands(env_conf: EnvConfigSet, shell: str = "bash") -> None: - """ - wrap commands into shell if there is redirect - - Args: - env_conf(EnvConfigSet): the core configuration object - shell(str, optional): shell command to use (Default value = "bash") - """ - if not env_conf["handle_redirect"]: - return - - # append shell just in case - env_conf["allowlist_externals"].append(shell) - - for command in env_conf["commands"]: - if len(command.args) < 3: # command itself, redirect and output - continue - - redirect, output = command.args[-2:] - if redirect not in (">", "2>", "&>"): - continue - - command.args = [ - shell, - "-c", - f"{Command(command.args[:-2]).shell} {redirect} {shlex.quote(output)}", - ] - - @impl def tox_add_env_config(env_conf: EnvConfigSet, state: State) -> None: """ @@ -103,12 +72,6 @@ def tox_add_env_config(env_conf: EnvConfigSet, state: State) -> None: default="", desc="import path for the version variable", ) - env_conf.add_config( - keys=["handle_redirect"], - of_type=bool, - default=False, - desc="wrap commands to handle redirects if any", - ) @impl @@ -124,5 +87,3 @@ def tox_before_run_commands(tox_env: ToxEnv) -> None: python_path = set_env.load("PYTHONPATH") if "PYTHONPATH" in set_env else None set_env.update(_extract_version(env_conf, python_path)) - - _wrap_commands(env_conf)