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

Simple initial uses of ExceptionGroup #3372

Merged
merged 5 commits into from
Jun 12, 2022

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Jun 11, 2022

Extracted from #3308 (see also #3175) for the sake of smaller and easier-to-read diffs.

I'll then try to pick up just the __notes__ changes in a separate PR, and defer the replacement of MultipleFailures until Pytest displays ExceptionGroup inner exceptions.

@Zac-HD Zac-HD requested a review from sobolevn June 11, 2022 08:41
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks! This was interesting. I'm still trying to wrap my head around the little details of ExceptionGroup implementation.

Also, a question about exceptiongroups package. It has this section: https://github.com/agronholm/exceptiongroup#notes-on-monkey-patching Can it be a problem for us in any way? 🤔

if errors:
if len(errors) == 1:
raise errors[0] from exc_value
raise BaseExceptionGroup("Cleanup failed", errors) from exc_value
Copy link
Member

Choose a reason for hiding this comment

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

Question: do we need to use from with exception groups? I've never tried it :)

Copy link
Member Author

Choose a reason for hiding this comment

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

https://docs.python.org/3/tutorial/errors.html#exception-chaining

It just indicates that we're deliberately replacing the previous exception, instead of hitting another error while handling it.

@Zac-HD
Copy link
Member Author

Zac-HD commented Jun 12, 2022

The monkey patching is actually pretty important here - without it, we wouldn't display eg notes on previous versions.

@Zac-HD Zac-HD merged commit 2ccf867 into HypothesisWorks:master Jun 12, 2022
@Zac-HD Zac-HD deleted the using-exceptiongroups branch June 12, 2022 17:13
@renefritze
Copy link

Just as an FYI, I've discovered that depending on the exceptiongroup RC might be somewhat problematic for people using mamba to install the conda package.
conda-forge/hypothesis-feedstock#730

@Zac-HD
Copy link
Member Author

Zac-HD commented Aug 10, 2022

Unfortunately there's not much I can do here; the conda-forge package for Hypothesis is not provided or endorsed by the Hypothesis maintainers.

My main reaction is "maybe mamba should support pre-releases then"!

@renefritze
Copy link

Unfortunately there's not much I can do here

Sure, I understand.

My main reaction is "maybe mamba should support pre-releases then"!

Right. That'll be my next step too, I guess.

@Zac-HD
Copy link
Member Author

Zac-HD commented Aug 10, 2022

Good luck! I do really appreciate the report, even if I can't help directly 😅

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.

3 participants