nox icon indicating copy to clipboard operation
nox copied to clipboard

Add a `default=True` argument to nox.session

Open Julian opened this issue 1 year ago • 6 comments

How would this feature be useful?

I'd like to write

@nox.session
def bar():
    pass

@nox.session(default=False)
def foo():
    pass

@nox.session
def baz():
    pass

as a DRYer alternative to:

nox.options.sessions = ["bar", "baz"]

@nox.session
def bar():
    pass

@nox.session
def foo():
    pass

@nox.session
def baz():
    pass

i.e. to be able to specify whether a session is run by default or not when defining it, rather than hardcoding the sessions that should be run.

Has this been considered before perhaps?

Describe the solution you'd like

Programmatically build up nox.options.sessions unless it's defined explicitly via the addition of a parameter (defaulting to True to match the current behavior) which defines whether a session is run by default or not.

Describe alternatives you've considered

Obviously there could be some noodling on what to call the parameter.

Anything else?

No response

Julian avatar Oct 06 '22 13:10 Julian

Sounds good to me! Using a parameter (instead of a variable) could be more human-readable, maybe?

Any thoughts from the maintainers?

DiddiLeija avatar Oct 06 '22 14:10 DiddiLeija