Skip to content

Don't suppress exception chaining for optional dependencies #43882

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

Merged
merged 7 commits into from
Oct 6, 2021

Conversation

takluyver
Copy link
Contributor

I've just been helping someone for whom the helpful error message appears to have obscured the real cause of the problem. Specifically, Jinja2 is present, but one of its dependencies is not. So the error message saying "Missing optional dependency: 'Jinja2'..." is rather confusing.

Automatic exception chaining is really great for things like this - you can provide a more descriptive error message while still having the original exception details available for inspection. I'd argue that it should only be disabled (raise ... from None) if you're absolutely sure that there will be no useful information in the original exception.

Copy link
Member

@mzeitlin11 mzeitlin11 left a comment

Choose a reason for hiding this comment

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

Thanks @takluyver, looks like a nice improvement! Can you please add a quick note in the whatsnew for 1.4 mentioning this improved error message? Also might be nice to have a test for this (if not too cumbersome)

@mzeitlin11 mzeitlin11 added Dependencies Required and optional dependencies Error Reporting Incorrect or improved errors from pandas labels Oct 4, 2021
@mzeitlin11 mzeitlin11 added this to the 1.4 milestone Oct 4, 2021
@takluyver
Copy link
Contributor Author

Thanks, 🤞 that test works. I'm editing from the web interface. 🙂

@pandas-dev pandas-dev deleted a comment from pep8speaks Oct 5, 2021
@mzeitlin11
Copy link
Member

close/reopen for CI

@mzeitlin11 mzeitlin11 closed this Oct 5, 2021
@mzeitlin11 mzeitlin11 reopened this Oct 5, 2021
@jreback jreback merged commit 07e885b into pandas-dev:master Oct 6, 2021
@jreback
Copy link
Contributor

jreback commented Oct 6, 2021

thanks @takluyver very nice!

@takluyver takluyver deleted the patch-1 branch October 6, 2021 08:20
@takluyver
Copy link
Contributor Author

Thanks all 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dependencies Required and optional dependencies Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants