Skip to content
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

Support custom session names in --keywords expression #492

Open
nawatts opened this issue Oct 6, 2021 · 3 comments · Fixed by #493
Open

Support custom session names in --keywords expression #492

nawatts opened this issue Oct 6, 2021 · 3 comments · Fixed by #493

Comments

@nawatts
Copy link
Contributor

nawatts commented Oct 6, 2021

How would this feature be useful?

Currently, providing a --keywords argument that is not a valid expression causes Nox to crash with a SyntaxError.

$ nox -k 'foo:bar'
Traceback (most recent call last):
  ...
  File "<string>", line 1
    foo:bar
       ^
SyntaxError: invalid syntax

The value of the --keywords argument should be a Python expression. That expression is evaluated to filter the list of sessions.

/~https://github.com/theacodes/nox/blob/a2bd140ed9702428d3fc93be9857879388f21ad0/nox/manifest.py#L347-L350

However, I don't think that's entirely obvious. The name of the argument is --keywords and the docs also refer to "pytest-style keywords".

The issue arises if the user attempts to do a keyword match on a custom session name, which may contain characters that are not valid in Python identifiers. Using one of those characters in the --keywords expression raises a SyntaxError when it is evaluated.

Nox could provide some guidance here on how to resolve the issue. With the current behavior (printing a SyntaxError and stack trace), it's not clear to the user whether the issue is an invalid argument or a bug in Nox.

Describe the solution you'd like

It would be nice if the keywords argument could support matching on session names, including characters that aren't allowed in Python identifiers.

Describe alternatives you've considered

Validating the keywords expression and printing a descriptive error message (#493) would help users resolve the error.

@FollowTheProcess
Copy link
Collaborator

Closing due to fix in #493 Thanks 🎉

@FollowTheProcess
Copy link
Collaborator

Sorry didn't fully read! Issue refers to a slightly different feature than the fix in #493. My bad!

@nawatts
Copy link
Contributor Author

nawatts commented Oct 6, 2021

Sorry, I did kind of conflate two separate, though related, issues here.

@nawatts nawatts changed the title Invalid --keywords expression raises a SyntaxError Support custom session names in --keywords expression Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants