-
-
Notifications
You must be signed in to change notification settings - Fork 169
Labels
Description
Current Behavior
The nox.options.keywords
configuration option makes the nox
command to error out when specified in noxfile.py
Expected Behavior
The noxfile.py
's nox.options.keywords
option should behave the same as the -k
command line flag.
Steps To Reproduce
- With this noxfile.py:
import nox
nox.options.keywords = ["ci and not test"]
@nox.session(tags=["ci", "lint"])
def style(session: nox.Session):
"""Run style checks."""
print("running style checks...")
@nox.session(tags=["ci", "test"])
def test(session: nox.Session):
"""Run integration tests with pytest."""
print("running tests...")
- Run:
nox -l
- See error:
Traceback (most recent call last):
File "/home/ubuntu/projects/mypkg/venv/bin/nox", line 8, in <module>
sys.exit(main())
~~~~^^
File "/home/ubuntu/projects/mypkg/venv/lib/python3.13/site-packages/nox/_cli.py", line 219, in main
exit_code = execute_workflow(args)
File "/home/ubuntu/projects/mypkg/venv/lib/python3.13/site-packages/nox/_cli.py", line 53, in execute_workflow
return workflow.execute(
~~~~~~~~~~~~~~~~^
global_config=args,
^^^^^^^^^^^^^^^^^^^
...<10 lines>...
),
^^
)
^
File "/home/ubuntu/projects/mypkg/venv/lib/python3.13/site-packages/nox/workflow.py", line 61, in execute
return_value = function_(*args, **kwargs)
File "/home/ubuntu/projects/mypkg/venv/lib/python3.13/site-packages/nox/tasks.py", line 231, in filter_manifest
ast.parse(global_config.keywords, mode="eval")
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.pyenv/versions/3.13.3/lib/python3.13/ast.py", line 54, in parse
return compile(source, filename, mode, flags,
_feature_version=feature_version, optimize=optimize)
TypeError: compile() arg 1 must be a string, bytes or AST object
Environment
- OS: Ubuntu 20.04
- Python: 3.13.3
- Nox: 2025.5.1
Anything else?
On the other hand the command nox -l -k "ci and not test"
works as expected and outputs the below:
Sessions defined in /home/ubuntu/projects/mypkg/noxfile.py:
* style -> Run style checks.
- test -> Run integration tests with pytest.
sessions marked with * are selected, sessions marked with - are skipped.
Additionally in the noxfile.py
I other values:
nox.options.keywords = "ci and not test" # fails with: ValueError: ("not_ validator child '<instance_of validator for type <class 'str'>>' did not raise a captured error", Attribute(name='keywords', default=NOTHING, validator=<optional validator for <deep_iterable validator for <not_ validator wrapping <instance_of validator for type <class 'str'>>, capturing (<class 'ValueError'>, <class 'TypeError'>)> iterables of <instance_of validator for type <class 'str'>>> or None>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type='None | Sequence[str]', converter=None, kw_only=True, inherited=False, on_setattr=None, alias='keywords'), <instance_of validator for type <class 'str'>>, 'ci and not test', (<class 'ValueError'>, <class 'TypeError'>))
nox.options.keywords = ["ci", "and", "not", "test"] # fails with: TypeError: compile() arg 1 must be a string, bytes or AST object