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

Change defer_to_* to be based on [Base]ExceptionGroup #23

Closed
wants to merge 6 commits into from

Conversation

TeamSpen210
Copy link

Trio will be removing MultiError in favour of using ExceptionGroup (via backport on <3.11). This renames multi_error_defer_toexcept_group_defer_to and changes the logic to detect BaseExceptionGroup instead of MultiError. Since MultiError is a subclass, this should still work with existing code. The old name has an alias that warns when used.

While I was editing the module, I also fully type hinted it.

@codecov-commenter
Copy link

codecov-commenter commented Dec 24, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (c908bc7) 100.00% compared to head (34d5ec8) 99.35%.

Files Patch % Lines
src/trio_util/_exceptions.py 91.66% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##            master      #23      +/-   ##
===========================================
- Coverage   100.00%   99.35%   -0.65%     
===========================================
  Files           15       15              
  Lines          454      468      +14     
===========================================
+ Hits           454      465      +11     
- Misses           0        3       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -36,7 +36,8 @@
package_dir={'': 'src'},
install_requires=[
'async_generator',
'trio >= 0.11.0'
'trio >= 0.11.0',
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that trio-util supports old, pre-ExceptionGroup versions of trio. As the primary user of trio-util, my own organization is still on trio 0.21. Effectively, this PR is disallowing trio < 0.22.

Comment on lines +179 to +186
def multi_error_defer_to(
*privileged_types: Type[BaseException],
propagate_multi_error: bool = True,
strict: bool = True,
) -> ContextManager[None]:
"""Deprecated alias for exceptgroup_defer_to()."""
import warnings
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

The renaming and warning probably isn't worth it (I suspect my org is the only one using these functions).

I'm not sure it even makes sense to carry these exception utilities into the future. They were introduced as a way to make a pre-ExceptionGroup world more manageable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't consider this only really being for pre-ExceptionGroup code. Might just close this then, if they should be effectively deprecated?

I should refine my statement: they were introduced as a way to make lack of except* syntax more manageable. Without the syntax, it's a burden for API users to deal with "exception Foo or Foo wrapped inside an exception group". The filtering utils of MultiError and the exceptiongroup shim don't help with it.

Since projects don't always have freedom to use the newest python versions, these utilities still have a place. But it's still probably the case that no one is using them or will miss them.

@TeamSpen210
Copy link
Author

I didn't consider this only really being for pre-ExceptionGroup code. Might just close this then, if they should be effectively deprecated?

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