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

Switch from MultipleFailures to PEP-654 ExceptionGroup #3308

Merged
merged 3 commits into from
Aug 2, 2022

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Apr 26, 2022

Using the new features from PEP-654 and PEP-678, exception groups and enriching exceptions with notes.

Draft because I'm not quite done updating tests yet - and will want to do some further manual confirmation that the output looks good too - but this will close #3175 when merged.

@Zac-HD Zac-HD added legibility make errors helpful and Hypothesis grokable interop how to play nicely with other packages labels Apr 26, 2022
@Zac-HD Zac-HD force-pushed the use-exceptiongroup branch 4 times, most recently from c76e787 to 557b8be Compare May 4, 2022 01:40
@Zac-HD Zac-HD force-pushed the use-exceptiongroup branch 2 times, most recently from 3eda335 to 36870b3 Compare June 15, 2022 09:29
Using the new features from PEP-654 and PEP-678, exception groups and enriching exceptions with notes
@Zac-HD Zac-HD marked this pull request as ready for review July 27, 2022 07:10
@Zac-HD
Copy link
Member Author

Zac-HD commented Jul 27, 2022

@HypothesisWorks/hypothesis-python-contributors - with Python 3.11 rc1 next Monday, I'm hoping to merge this soon.

  • 🙏 standard code-review for a big change would be appreciated.
  • 👂 just try using it! Do you like the new reporting? Has anything gone missing or broken for your use-cases?
  • 🤔 I've disabled multiple-bug reporting for Pytest traceback modes which don't support ExceptionGroup yet. Thoughts?

@honno
Copy link
Member

honno commented Aug 1, 2022

Had been using this for a bit last week for a test suite that uses Hypothesis extensively (but not particularly weirdly), and this didn't break anything... take that as you will!

The only change I've felt is yeah, not seeing the multiple tracebacks when there are multiple failures in a typical pytest run.

Leaving sub-exception traceback display for pytest to support properly sounds reasonable to me. Even if pytest did print the tracebacks properly right now, there'd still be a lag in users using it, so it's not like we can escape the disruption. I certainly see for our/your sanity that we don't want to build/maintain some hacky interim solution either.

Just to note, the current --tb=native ASCII tree representation of "exception hierarchy" is nice, but looks a bit jarring for sub-exceptions that has text exceeding your terminals columns.

  + Exception Group Traceback (most recent call last):
  |   ...
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "..............................................
.............................................."
    |   etc.

I suppose this is the kind of stuff that has got you pytest folks interested in adopting Rich heh. In any case, I still think this tree is preferable to how Hypothesis currently displays multiple tracebacks.

EDIT: oh the tree is just the traceback message from ExceptionGroup? ahh

@Zac-HD
Copy link
Member Author

Zac-HD commented Aug 2, 2022

Knowing that it works in practice is super useful, thank you! I know it's well-tested, but whether the tests cover all the use-cases is harder to check 😅

Even if pytest did print the tracebacks properly right now, there'd still be a lag in users using it, so it's not like we can escape the disruption.

Indeed - download stats indicate that ~40% downloads are for the latest version, which was released in April, and based on other projects I track loosely there's something like 30% of downloads usually unpinned.

@Zac-HD Zac-HD merged commit cc6f84e into HypothesisWorks:master Aug 2, 2022
@Zac-HD Zac-HD deleted the use-exceptiongroup branch August 2, 2022 04:40
@Zac-HD
Copy link
Member Author

Zac-HD commented Aug 2, 2022

@honno: https://github.com/data-apis/dataframe-interchange-tests/blob/73e4f74eb53eb04bc9632ea243d8b167c458dbfe/tests/test_from_dataframe.py#L11-L14

Looking at this test, you get exhaustive coverage of A -> B -> A - but it's also possible that there are bugs of the form A -> B -> C -> D -> A! I'd consider pulling out the body of this test into a helper function, and then sharing it with a new test that does multiple conversions with st.lists(st.sampled_from(library_infos), min_size=2, unique=True).

@honno
Copy link
Member

honno commented Aug 2, 2022

Looking at this test, you get exhaustive coverage of A -> B -> A - but it's also possible that there are bugs of the form A -> B -> C -> D -> A! I'd consider pulling out the body of this test into a helper function, and then sharing it with a new test that does multiple conversions with st.lists(st.sampled_from(library_infos), min_size=2, unique=True).

Ayup, I think with just the single round-trips I wrote a gazillion bug reports for adopting libraries, so I kinda forgot to do this heh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop how to play nicely with other packages legibility make errors helpful and Hypothesis grokable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Experiment with ExceptionGroup and BaseException.add_note() (in Python 3.11)
2 participants