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

Improve the PackageLoader error message #1706

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

LilyFoote
Copy link

@LilyFoote LilyFoote commented Aug 11, 2022

Explain why the PackageLoader failed when the package_path directory is missing.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

LilyFoote and others added 3 commits August 11, 2022 15:22
This exception is raised when the `package_path` directory (default "templates") is not
found, so explain this.
@LilyFoote
Copy link
Author

I don't think the first 4 items of the checklist are relevant here, but happy to be corrected.

@LilyFoote
Copy link
Author

@davidism Here's that PR.

f"The {package_name!r} package was not installed in a"
" way that PackageLoader understands."
f"PackageLoader could not find a '{package_path}' directory for the "
f"{package_name!r} package."
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the original message was about not being able to find the package properly. i.e. At line 315, roots would still be an empty list, because it failed to find anything.

So, it seems better to me if the original error is raised if roots is empty, otherwise raise this new error message if we don't break from the loop (i.e. add an else to the for loop).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The error message from PackageLoader could be more helpful
2 participants