nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: wntrblm/nox
Pull request #653 (2022-09-23 02:01:37)

Fix example in docs using `session.posargs`
Current example feeds `session.posargs` directly into `session.run`. I don't _think_ this works—as `session.posargs` is a list. Added an unpacking argument `*` as a quick fix.

---

Thanks for the great work here!


Patch:
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index 918f829..9189189 100644
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -329,7 +329,7 @@ You can also pass the notified session positional arguments:
     def consume_thing(session):
         # The 'consume' command has the arguments
         # sent to it from the 'prepare_thing' session
-        session.run("consume", "thing", session.posargs)
+        session.run("consume", "thing", *session.posargs)
 
 Note that this will only have the desired effect if selecting sessions to run via the ``--session/-s`` flag. If you simply run ``nox``, all selected sessions will be run.
 
diff --git a/nox/command.py b/nox/command.py
index 8a55c1f..9b828b4 100644
--- a/nox/command.py
+++ b/nox/command.py
@@ -71,8 +71,7 @@ def _clean_env(env: dict[str, str] | None) -> dict[str, str] | None:
 
 
 def _shlex_join(args: Sequence[str]) -> str:
-    # shlex.join() was added in Python 3.8
-    return " ".join(shlex.quote(arg) for arg in args)
+    return " ".join(shlex.quote(os.fspath(arg)) for arg in args)
 
 
 def run(


Test patch:
diff --git a/tests/test_command.py b/tests/test_command.py
index a05ab82..efda160 100644
--- a/tests/test_command.py
+++ b/tests/test_command.py
@@ -22,6 +22,7 @@ import signal
 import subprocess
 import sys
 import time
+from pathlib import Path
 from textwrap import dedent
 from unittest import mock
 
@@ -112,6 +113,19 @@ def test_run_verbosity_failed_command(capsys, caplog):
     assert not logs
 
 
+@pytest.mark.skipif(
+    platform.system() == "Windows",
+    reason="See https://github.com/python/cpython/issues/85815",
+)
+def test_run_non_str():
+    result = nox.command.run(
+        [Path(PYTHON), "-c", "import sys; print(sys.argv)", Path(PYTHON)],
+        silent=True,
+    )
+
+    assert PYTHON in result
+
+
 def test_run_env_unicode():
     result = nox.command.run(
         [PYTHON, "-c", 'import os; print(os.environ["SIGIL"])'],