-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
[BUG] --no-reuse-existing-virtualenvs doesn't seem to work #488
Comments
Thanks for reporting this. This appears to be the culprit: Judging from a quick look at the history, It would be nice to support this use case as well. (Could we check |
So the behavior could be:
Footnotes |
Hmm.. Ideally we'd do the following (but it's more work):
So this would split your Consider this noxfile: import nox
nox.options.reuse_existing_virtualenvs = False
@nox.session(reuse_venvs=True):
def test(session):
pass I'd be surprised if the On the other hand, I'd expect |
And, for completeness, your import nox
nox.options.reuse_existing_virtualenvs = True
@nox.session(reuse_venvs=False):
def test(session):
pass So this would not reuse |
There is a very easy workaround for the above, though - don't set Same is true if you set But I see your point. |
This behavior is definitely ambiguous if we're just using True/False. What do y'all think using "yes", "no", "always" and "never"? So:
The |
Yes, I think that solves it nicely! |
I think this is what you meant, but just to be clear:
I think that's the proposal? |
And then some deprecation/removal of |
@henryiii that doesn't cover the same set of behaviors I described. Also, we can keep the existing long name- I was just being brief. If y'all wanna shorten it to reuse with the old name being an alias go ahead. |
I do like I feel like allowing the common line option to be more expressive than the local setting makes this a bit simpler, but still covers the main uses. Passing a string on the command line is more natural than in a function call, and it would be nice to only have a change to the command line usage, and maybe a single global line, rather than changing and complicating all session definitions. |
Also, |
There is lots of precedence for this in existing Python code. I still think using True/False for the decorator leads to ambiguity, and especially if the command-line/global option is a string it feels odd to have the per-session one be a bool. It also is strange to have a value be valid for global options but not for a per-session option. Since this describes a specific behavior and not a simple on/off flag, I lean towards using "yes"/"no"/"always"/"never. We must retain backwards compatibility, and the easiest way to do that is have True map to "yes" and False/None/unset map to "no". |
This is fine when it's needed. I'm aware of Literals, python's string comparisons for short strings, etc. My worry is about ambiguity and over-specification. Also, there's also lots of bad precedence too. ;) False and None are useful different behaviors. session.options.reuse_venv = "yes" (could be mapped to True?)
@session(reuse_venv=False)
def test...
@session
def docs...
@session
def lint...
... That is, this is switching the "default" to reuse, but on the small number of sessions that build something that should not be reused, then that can be specified. (most of my files are likely this way, most venvs are reusable) For the string version, that now has to be: ...
@session(reuse_venv="never") # False would not work, would be mapped to no - and 'yes' wins over 'no'.
def test... Hoever, passing Up to you, just my thoughts. |
If you wanted strings for reuse_venv, "default", "no", and "yes" would be identical to "no", "never", and "yes"/"always" (there is no difference between "yes" and "always" when set locally, by the way). But if you have different literals, and three of them, with these meanings, why not just stay with None/True/False? |
Alright, I think I understand what you're getting at:
If that's the case, that works for me. |
I think I am running into this problem. I have a import nox
from nox_poetry import Session, session
nox.options.reuse_existing_virtualenvs = True
...
@session(reuse_venv=False)
def licenses(s: Session) -> None:
s.install(".", "pip-licenses")
s.run("pip-licenses", *s.posargs) I expected that
|
@johnthagen because of that (False or True) Lines 718 to 720 in b15909e
|
Describe the bug
Adding
--no-reuse-existing-virtualenvs
does not seem to ignore the cache, and instead just reuses the existing environments anyway. Happened on the previous version, and then did abrew upgrade
, and 2021.10.1 also has this problem. Unless I misunderstand this option, pretty sure it's broken.How to reproduce
(simplified slightly, should be unimportant)
Expected behavior
The existing virtual environment should not have been reused. (It really was, not just visually; I was trying to remove an item from the install list, but it remained installed).
The text was updated successfully, but these errors were encountered: