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

ENH: don't drop ImportError tracebacks for lazily-loaded optional dependencies #4226

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

neutrinoceros
Copy link
Member

@neutrinoceros neutrinoceros commented Nov 24, 2022

PR Summary

Closes #4224

The original issue I reported there had nothing to do with yt, but it took me a couple hours to even find out that yt was indeed not the culprit, because the initially insightful error message was completely replaced by a less informative one. This patch makes sure that, failing to import an optional dependency, we always report the original error (because as we learned, the problem might not be that the package isn't installed, it can also be broken). That is, alongside with additional insight specific to yt.

The implementation is more elegant in Python 3.11 thanks to the newly introduced exception notes, but I think I was able to make the behaviour consistent with older versions too.

I intend this patch as backward compatible in case anyone downstream relies on the NotAModule class, but I don't think it needs to be backported

@neutrinoceros neutrinoceros added the enhancement Making something better label Nov 24, 2022
@neutrinoceros neutrinoceros added this to the 4.2.0 milestone Nov 24, 2022
@neutrinoceros neutrinoceros marked this pull request as ready for review November 24, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Making something better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: CI instability (xref upstream breakage from setuptools+numpy+astropy)
3 participants