File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ Version history
3
3
4
4
This library adheres to `Semantic Versioning 2.0 <http://semver.org/ >`_.
5
5
6
+ **UNRELEASED **
7
+
8
+ - Corrected the type annotation of the exception handler callback to accept a
9
+ ``BaseExceptionGroup `` instead of ``BaseException ``
10
+
6
11
**1.2.0 **
7
12
8
13
- Added special monkeypatching if `Apport <https://github.com/canonical/apport >`_ has
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ containing more matching exceptions.
54
54
55
55
Thus, the following Python 3.11+ code:
56
56
57
- .. code-block :: python3
57
+ .. code-block :: python
58
58
59
59
try :
60
60
...
@@ -66,15 +66,15 @@ Thus, the following Python 3.11+ code:
66
66
67
67
would be written with this backport like this:
68
68
69
- .. code-block :: python3
69
+ .. code-block :: python
70
70
71
- from exceptiongroup import ExceptionGroup , catch
71
+ from exceptiongroup import BaseExceptionGroup , catch
72
72
73
- def value_key_err_handler(excgroup: ExceptionGroup ) -> None:
73
+ def value_key_err_handler (excgroup : BaseExceptionGroup ) -> None :
74
74
for exc in excgroup.exceptions:
75
75
print (' Caught exception:' , type (exc))
76
76
77
- def runtime_err_handler(exc: ExceptionGroup ) -> None:
77
+ def runtime_err_handler (exc : BaseExceptionGroup ) -> None :
78
78
print (' Caught runtime error' )
79
79
80
80
with catch({
@@ -91,7 +91,9 @@ Suppressing exceptions
91
91
92
92
This library contains a backport of the ``contextlib.suppress() `` context manager from
93
93
Python 3.12.1. It allows you to selectively ignore certain exceptions, even when they're
94
- inside exception groups::
94
+ inside exception groups:
95
+
96
+ .. code-block :: python
95
97
96
98
from exceptiongroup import suppress
97
99
Original file line number Diff line number Diff line change 11
11
from ._exceptions import BaseExceptionGroup
12
12
13
13
if TYPE_CHECKING :
14
- _Handler = Callable [[BaseException ], Any ]
14
+ _Handler = Callable [[BaseExceptionGroup [ Any ] ], Any ]
15
15
16
16
17
17
class _Catcher :
You can’t perform that action at this time.
0 commit comments