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

DM-34386: Improve doImport error message. #122

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/utils/doImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def tryImport(
# Move element from module to file and try again
infileComponents.insert(0, moduleComponents.pop())

raise ModuleNotFoundError(f"Unable to import {importable}")
# Fell through without success.
extra = f"({previousError})" if previousError is not None else ""
raise ModuleNotFoundError(f"Unable to import {importable!r} {extra}")


def doImportType(importable: str) -> Type:
Expand Down