Skip to content

Commit 1c6af24

Browse files
authored
fix: warn user when first argument to session.run is a list (#786)
1 parent d59e1ac commit 1c6af24

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

nox/sessions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ def run(
379379
if not args:
380380
raise ValueError("At least one argument required to run().")
381381

382+
if len(args) == 1 and isinstance(args[0], (list, tuple)):
383+
msg = "First argument to `session.run` is a list. Did you mean to use `session.run(*args)`?"
384+
raise ValueError(msg)
385+
382386
if self._runner.global_config.install_only:
383387
logger.info(f"Skipping {args[0]} run, as --install-only is set.")
384388
return None

tests/test_sessions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,12 @@ def test___dict__(self):
842842
expected = {name: getattr(session, name) for name in session.__slots__}
843843
assert session.__dict__ == expected
844844

845+
def test_first_arg_list(self):
846+
session, _ = self.make_session_and_runner()
847+
848+
with pytest.raises(ValueError):
849+
session.run(["ls", "-al"])
850+
845851

846852
class TestSessionRunner:
847853
def make_runner(self):

0 commit comments

Comments
 (0)