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

Show error message when keywords expression contains a syntax error #493

Merged
merged 2 commits into from Oct 6, 2021

Conversation

nawatts
Copy link
Contributor

@nawatts nawatts commented Oct 6, 2021

Related to #492.

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

This change validates the keywords argument using ast.parse and prints an error message if it is not a valid expression.

$ nox -k 'foo:bar'
nox > Error while collecting sessions: keywords argument must be a Python expression.

@FollowTheProcess
Copy link
Collaborator

Hi @nawatts, thanks for the contribution!

This looks good to me 👍🏻

Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nawatts

Just waiting for the CI to pass after the merge.

@cjolowicz cjolowicz merged commit 536e9d1 into wntrblm:main Oct 6, 2021
@FollowTheProcess FollowTheProcess linked an issue Oct 6, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Support custom session names in --keywords expression
3 participants