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

Add friendlier message if no noxfile.py #463

Merged
merged 3 commits into from Jul 10, 2021
Merged

Add friendlier message if no noxfile.py #463

merged 3 commits into from Jul 10, 2021

Conversation

FollowTheProcess
Copy link
Collaborator

#462

Add a friendlier message on the specific case that user is calling
nox from within a directory with no noxfile.

Existing test for this case modified and two additional tests
added to ensure lower level errors are still handled further down.

Fixes #462.

Add a friendlier message on the specific case that user is calling
nox from within a directory with no noxfile.

Existing test for this case modified and two additional tests
added to ensure lower level errors are still handled further down.
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.

Thank you for the PR!

Please see the inline comment.

nox/tasks.py Outdated
Comment on lines 72 to 74
except FileNotFoundError:
logger.error(f"noxfile.py not found in {noxfile_parent_dir!r}.")
return 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to generalize this error message for the case where the Noxfile is not named noxfile.py.

I'd suggest to use the exception handler for IOError below this one as a template:

Suggested change
except FileNotFoundError:
logger.error(f"noxfile.py not found in {noxfile_parent_dir!r}.")
return 2
except FileNotFoundError:
logger.error("Failed to load Noxfile {}: no such file".format(global_config.noxfile))
return 2

Replacing logger.exception with logger.error avoids the traceback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot!, I'll tweak that now.

@cjolowicz cjolowicz merged commit 8ee3ebe into wntrblm:main Jul 10, 2021
@FollowTheProcess FollowTheProcess deleted the nicer-file-not-found branch July 11, 2021 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants