-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
misleading error "Failed to load Noxfile noxfile.py, no such file exists." #566
Comments
@weatherfrog Thanks for raising this! I agree the given error is not exactly helpful. PR's are always welcome! Just thinking about this in more detail, would something like this work for you:
This could be implemented with something along the lines of: except FileNotFoundError as err:
if err.filename.lower() == global_config.noxfile.lower():
message = (
f"Failed to load Noxfile {global_config.noxfile}, no such file exists."
)
else:
message = (
f"File declared in {global_config.noxfile} not found: {err.filename}"
)
logger.error(message)
return 2 This has the added advantages that:
What do you think? |
@FollowTheProcess Thanks for the immediate response. I agree, the upfront check is not great. I like your proposition. The only problem I'm seeing is that you never get to see the stack trace, i.e., you won't know where the error occurred. I think I would just go with except FileNotFoundError as err:
if err.filename.lower() == global_config.noxfile.lower():
logger.error(
f"Failed to load Noxfile {global_config.noxfile}, no such file exists."
)
return 2
else:
raise err I mean, other exceptions are not caught either. So why catch general But I can live with your variant, too, of course. It's your library. You decide. 😀 |
If the Noxfile cannot be read, the Would it make sense then to move the call to |
@cjolowicz That's a great idea! I've just experimented with putting
The only additional thing is we might want to change the exceptions raised in |
I'm not familiar with the |
To me, this means that these checks should be omitted. If there really is an unexpected issue in |
Yeah I think you're right, to be honest the only real reason I put them in originally was to cover off the There's a few more e.g. |
Oh I see. So the return types generally allow |
Describe the bug
If a
FileNotFoundError
occurs somewhere on module-level withinnoxfile.py
, nox will display a misleading error:The problem is here: https://github.com/theacodes/nox/blob/main/nox/tasks.py#L109
This
except
clause is harmful. Something like this would solve the problem:Shall I create a PR?
How to reproduce
noxfile.py:
Expected behavior
The stack trace of the actual error should be visible.
The text was updated successfully, but these errors were encountered: