Skip to content

Add a default=True argument to nox.session #654

@Julian

Description

@Julian

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions