Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nox does not raise an error when wrong option is set: reuse_venv #869

Closed
smarie opened this issue Oct 18, 2024 · 1 comment · Fixed by #872
Closed

Nox does not raise an error when wrong option is set: reuse_venv #869

smarie opened this issue Oct 18, 2024 · 1 comment · Fixed by #872
Labels

Comments

@smarie
Copy link
Contributor

smarie commented Oct 18, 2024

Current Behavior

I was giving a training today and I wanted to show how nox can be configured to reuse existing virtual environments.
This is what I wrote in noxfile.py :

nox.options.reuse_venv = True

Unfortunately nox does not raise any error and continues to run ! I did not realize it but if you look carefully it actually tells us that it (re)creates the env :

image

This is the correct way to tell nox to reuse virtual environments for all sessions :

nox.options.reuse_existing_virtualenvs = True

And we can check it that way

image

Expected Behavior

I would expect that an unsupported option in noxfile.py

nox.options.reuse_venv = True

would raise an error when running nox

Steps To Reproduce

see above

Environment

- OS: Windows 10
- Python: 3.11.4
- Nox: 2024.4.15

Anything else?

See #488 for related recent PR

@smarie smarie added the bug label Oct 18, 2024
@smarie smarie changed the title Nox does not raise an error when wrong option is set Nox does not raise an error when wrong option is set: reuse_venv Oct 18, 2024
@smarie smarie changed the title Nox does not raise an error when wrong option is set: reuse_venv Nox does not raise an error when wrong option is set: reuse_venv Oct 18, 2024
@henryiii
Copy link
Collaborator

henryiii commented Oct 26, 2024

reuse_venv is actually a valid nox.options value. You are correct, though, that any invalid assignment is ignored - this has bugged me before. I've opened a PR.

In your case, reuse_venv takes a string: no, yes, never, and always. A second followup (more invasive, though) could be to validate these, say using attrs. A simpler fix just for this one would be to error if it's not set to one of those four strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants