From 6dc64f2373ad4adcf16e0ecc8afdb6727e088b33 Mon Sep 17 00:00:00 2001 From: Martin Imre Date: Fri, 26 Apr 2024 13:39:46 +0200 Subject: [PATCH 1/4] fix(parser): Fix --discover parsed incorrectly from env The flag was missing the type specification (`of_type`) and thus parse.get_env_var did not execute the branch for list, but rather for single variables. The fallback in Converter led to a call to `list("abc")`, which resulted int a list of characters (["a", "b", "c"]). --- src/tox/config/cli/parser.py | 1 + tests/config/cli/test_cli_env_var.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py index 7afe87753..24e06b5a7 100644 --- a/src/tox/config/cli/parser.py +++ b/src/tox/config/cli/parser.py @@ -232,6 +232,7 @@ def __call__( dest="discover", nargs="+", metavar="path", + of_type=list[str], help="for Python discovery first try the Python executables under these paths", default=[], ) diff --git a/tests/config/cli/test_cli_env_var.py b/tests/config/cli/test_cli_env_var.py index 3c870ae9e..7f265c78c 100644 --- a/tests/config/cli/test_cli_env_var.py +++ b/tests/config/cli/test_cli_env_var.py @@ -84,6 +84,7 @@ def test_env_var_exhaustive_parallel_values( monkeypatch.setenv("TOX_PARALLEL", "3") monkeypatch.setenv("TOX_PARALLEL_LIVE", "no") monkeypatch.setenv("TOX_OVERRIDE", "a=b;c=d") + monkeypatch.setenv("TOX_DISCOVER", "/foo/bar;/bar/baz;/baz/foo") options = get_options() assert vars(options.parsed) == { @@ -93,7 +94,7 @@ def test_env_var_exhaustive_parallel_values( "default_runner": "virtualenv", "develop": False, "devenv_path": None, - "discover": [], + "discover": ["/foo/bar", "/bar/baz", "/baz/foo"], "env": CliEnv(["py37", "py36"]), "force_dep": [], "hash_seed": ANY, From 39c592b8026d092badc720c153f9a6a699b76ae6 Mon Sep 17 00:00:00 2001 From: Martin Imre Date: Fri, 26 Apr 2024 19:04:02 +0200 Subject: [PATCH 2/4] doc(parser): Rephrase `--discover` help to avoid confusion The flag expects a list of python executables, but not paths. Eg `--discover /foo/bar/python` is good, `--discover /foo/bar` or `--discover /foo/bar/` won't work. --- src/tox/config/cli/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py index 24e06b5a7..068fbca23 100644 --- a/src/tox/config/cli/parser.py +++ b/src/tox/config/cli/parser.py @@ -233,7 +233,7 @@ def __call__( nargs="+", metavar="path", of_type=list[str], - help="for Python discovery first try the Python executables under these paths", + help="for Python discovery first try these Python executables", default=[], ) list_deps = sub_parser.add_mutually_exclusive_group() From 7d736410b951dcdaac61cca80e8ed0b160b1318b Mon Sep 17 00:00:00 2001 From: Martin Imre Date: Fri, 26 Apr 2024 19:19:37 +0200 Subject: [PATCH 3/4] dcos(changelog): Add changelog fragments for #3272 and #3274 --- docs/changelog/3272.bugfix.rst | 1 + docs/changelog/3274.doc.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 docs/changelog/3272.bugfix.rst create mode 100644 docs/changelog/3274.doc.rst diff --git a/docs/changelog/3272.bugfix.rst b/docs/changelog/3272.bugfix.rst new file mode 100644 index 000000000..7877bd400 --- /dev/null +++ b/docs/changelog/3272.bugfix.rst @@ -0,0 +1 @@ +Fix broken input parsing for ``--discover`` flag. - by :user:`mimre25` diff --git a/docs/changelog/3274.doc.rst b/docs/changelog/3274.doc.rst new file mode 100644 index 000000000..d2ffe6028 --- /dev/null +++ b/docs/changelog/3274.doc.rst @@ -0,0 +1 @@ +Rephrase ``--discover`` flag's description to avoid confusion between paths and executables. - by :user:`mimre25` From f3d00633e699949be39af476143eec7f6f52f3fd Mon Sep 17 00:00:00 2001 From: Martin Imre Date: Fri, 26 Apr 2024 19:50:45 +0200 Subject: [PATCH 4/4] fixup! fix(parser): Fix --discover parsed incorrectly from env py38 typehint fixes --- src/tox/config/cli/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py index 068fbca23..707c7fc8a 100644 --- a/src/tox/config/cli/parser.py +++ b/src/tox/config/cli/parser.py @@ -232,7 +232,7 @@ def __call__( dest="discover", nargs="+", metavar="path", - of_type=list[str], + of_type=List[str], help="for Python discovery first try these Python executables", default=[], )