Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 15, 2024
1 parent 3d17e19 commit 0fdf1ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/exceptiongroup/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ def __repr__(self) -> str:

class ExceptionGroup(BaseExceptionGroup[_ExceptionT_co], Exception):
def __new__(
cls: type[_ExceptionGroupSelf], __message: str, __exceptions: Sequence[_ExceptionT_co]
cls: type[_ExceptionGroupSelf],
__message: str,
__exceptions: Sequence[_ExceptionT_co],
) -> _ExceptionGroupSelf:
return super().__new__(cls, __message, __exceptions)

Expand Down
14 changes: 8 additions & 6 deletions tests/type_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

# code snippets from the README


def value_key_err_handler(excgroup: BaseExceptionGroup) -> None:
for exc in excgroup.exceptions:
print('Caught exception:', type(exc))
print("Caught exception:", type(exc))


def runtime_err_handler(exc: BaseExceptionGroup) -> None:
print('Caught runtime error')
print("Caught runtime error")


with catch({
(ValueError, KeyError): value_key_err_handler,
RuntimeError: runtime_err_handler
}):
with catch(
{(ValueError, KeyError): value_key_err_handler, RuntimeError: runtime_err_handler}
):
...


Expand Down

0 comments on commit 0fdf1ea

Please sign in to comment.