Skip to content

Provide a configuration option to name parametrized sessions without special characters #1075

@namurphy

Description

@namurphy

Proposed change

I'd like there to be a way for session names to be created with dashes instead of special characters. For example, tests-3.14(resolution='highest') would instead be tests-3.14-resolution-highest. This would be akin to the naming scheme used by tox.

Hyphenated names could be enabled via a configuration option:

nox.option.hyphenated_session_names = True

An additional possibility would be to create a command line option, like --hyphenated-session-names or -h.

Background

Currently, the names of parametrized sessions include special characters like (i.e., (, ), =, '). Some example session names are tests(resolution='highest'), tests-3.12(resolution='lowest-direct'), and tests-3.14(highest).

If we naively pass the name of one of these sessions to nox -s, we'd get an error:

$ nox -s tests-3.14(resolution='highest')
bash: syntax error near unexpected token `('

It's necessary to either put the session name in quotes or escape the special characters.

nox -s "tests-3.14(resolution='highest')"
nox -s tests-3.14\(resolution\=\'highest\'\)

How would this feature be useful?

In addition to making command-line usage a little more user-friendly, the main use case I have in mind is autocompletions. I've been experimenting with autocompletions for the fish shell, and I've been running into difficulty doing this with nox sessions because of the use of special characters. In particular, the special characters are automatically getting escaped, which makes the command a lot less readable.

Thank you to everyone involved with creating this awesome tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions