Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

native except handler API #21

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

maxfischer2781
Copy link

@maxfischer2781 maxfischer2781 commented Jun 19, 2020

This PR is a prototype implementation of #20. Notable additions and changes include:

  • ExceptionGroup is "Generic" and can be specialised by exceptions. This allows catching specific groups, e.g. except ExceptionGroup[KeyError, TypeError] as exc_group:.
  • Added new metaclass to implement ExceptionGroup[A, B, C] and issubclass(exc_group, ExceptionGroup[ABC]).
  • ExceptionGroup attributes .exceptions and .sources are tuples instead of lists. This is intended to prevent inconsistencies between the type and its attributes.

This PR does not change:

  • ExceptionGroup having .message, .exceptions and .sources attributes.
  • A bare except ExceptionGroup: catching all possible ExceptionGroups.
  • Existing API for splitting/catching sub-exceptions.
  • There is no "sub-handler" API as part of this PR.

@maxfischer2781 maxfischer2781 changed the title draft for native except handler API [WIP] native except handler API Jun 19, 2020
@codecov
Copy link

codecov bot commented Jun 19, 2020

Codecov Report

Merging #21 into master will increase coverage by 3.32%.
The diff coverage is 82.85%.

@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
+ Coverage   66.55%   69.88%   +3.32%     
==========================================
  Files          11       12       +1     
  Lines         311      425     +114     
  Branches       28       49      +21     
==========================================
+ Hits          207      297      +90     
- Misses        101      115      +14     
- Partials        3       13      +10     
Impacted Files Coverage Δ
exceptiongroup/_tests/test_exceptiongroup.py 88.76% <73.68%> (-11.24%) ⬇️
exceptiongroup/_exception_group.py 85.85% <85.85%> (ø)
exceptiongroup/__init__.py 100.00% <100.00%> (ø)
exceptiongroup/_monkeypatch.py 31.25% <100.00%> (ø)
exceptiongroup/_tools.py 56.06% <100.00%> (ø)

@maxfischer2781 maxfischer2781 marked this pull request as ready for review June 19, 2020 22:03
@maxfischer2781
Copy link
Author

As a first draft, this is basically done. Let me know if there is anything else that I should add, or something that needs clarification or discussing.

@maxfischer2781 maxfischer2781 changed the title [WIP] native except handler API native except handler API Nov 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant