diff --git a/nox/sessions.py b/nox/sessions.py index a98916f4..1ecacf04 100644 --- a/nox/sessions.py +++ b/nox/sessions.py @@ -379,6 +379,10 @@ def run( if not args: raise ValueError("At least one argument required to run().") + if len(args) == 1 and isinstance(args[0], (list, tuple)): + msg = "First argument to `session.run` is a list. Did you mean to use `session.run(*args)`?" + raise ValueError(msg) + if self._runner.global_config.install_only: logger.info(f"Skipping {args[0]} run, as --install-only is set.") return None diff --git a/tests/test_sessions.py b/tests/test_sessions.py index 24ebd635..3b8c53d6 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -842,6 +842,12 @@ def test___dict__(self): expected = {name: getattr(session, name) for name in session.__slots__} assert session.__dict__ == expected + def test_first_arg_list(self): + session, _ = self.make_session_and_runner() + + with pytest.raises(ValueError): + session.run(["ls", "-al"]) + class TestSessionRunner: def make_runner(self):