Skip to content

Allow session.run(quiet=True) to return stdout and stderr separately #1053

@felixfontein

Description

@felixfontein

How would this feature be useful?

When calling programs that print machine-readable output on stdout (for example as JSON) and warnings on stderr (for example as text messages), having the combined output is not helpful since you now have valid JSON mixed with lines that make it invalid. Being able to obtain these outputs separately (for example as with subprocess.run) would make this a lot easier then trying to separate the combined output into parsable JSON and unrelated text.

Describe the solution you'd like

This could be an additional parameter to session.run(), like capture: bool = False. Though that function already has quite a few arguments.

capture could work by returning None if the command isn't run, or a tuple (stdout, stderr) (or (stdout, stderr, rc), while we're at it - see "Anything else?" below).

Describe alternatives you've considered

Directly using subprocess.run(). Getting that to use the session's venv though and global config parameters like no_install is non-trivial, and I'm not sure whether it's fully possible at all without accessing private nox internals.

Anything else?

Having access to the exact return code (and the possibility to disable nox's return code check) could also be helpful in some cases.

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