pep 654: Fix indentation to use consistent 4 spaces in all snippets (#1833)

This commit is contained in:
Yury Selivanov 2021-02-22 12:24:54 -08:00 committed by GitHub
parent aebbd8c4fc
commit 3daf8f2199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 143 additions and 123 deletions

View File

@ -145,13 +145,20 @@ contains only those exceptions for which the condition is true:
.. code-block::
>>> eg = ExceptionGroup("one",
... [TypeError(1),
... ExceptionGroup("two",
... [TypeError(2), ValueError(3)]),
... ExceptionGroup("three",
... [OSError(4)])
... ])
>>> eg = ExceptionGroup(
... "one",
... [
... TypeError(1),
... ExceptionGroup(
... "two",
... [TypeError(2), ValueError(3)]
... ),
... ExceptionGroup(
... "three",
... [OSError(4)]
... )
... ]
... )
>>> traceback.print_exception(eg)
ExceptionGroup: one
------------------------------------------------------------
@ -386,9 +393,12 @@ recursively, using the ``ExceptionGroup.split()`` method:
>>> try:
... raise ExceptionGroup(
... "eg",
... [ValueError('a'),
... [
... ValueError('a'),
... TypeError('b'),
... ExceptionGroup("nested", [TypeError('c'), KeyError('d')])
... ExceptionGroup(
... "nested",
... [TypeError('c'), KeyError('d')])
... ]
... )
... except *TypeError as e1:
@ -411,7 +421,10 @@ clauses, the remaining part of the ``ExceptionGroup`` is propagated on:
>>> try:
... try:
... raise ExceptionGroup(
... "msg", [ValueError('a'), TypeError('b'), TypeError('c'), KeyError('e')]
... "msg", [
... ValueError('a'), TypeError('b'),
... TypeError('c'), KeyError('e')
... ]
... )
... except *ValueError as e:
... print(f'got some ValueErrors: {e!r}')
@ -512,13 +525,17 @@ the original ``ExceptionGroup``:
>>> try:
... try:
... raise ExceptionGroup("eg",
... [ValueError(1),
... raise ExceptionGroup(
... "eg",
... [
... ValueError(1),
... TypeError(2),
... OSError(3),
... ExceptionGroup(
... "nested",
... [OSError(4), TypeError(5), ValueError(6)])])
... [OSError(4), TypeError(5), ValueError(6)])
... ]
... )
... except *ValueError as e:
... print(f'*ValueError: {e!r}')
... raise
@ -546,13 +563,17 @@ merged with the unhandled ``TypeErrors``.
>>> try:
... try:
... raise ExceptionGroup("eg",
... [ValueError(1),
... raise ExceptionGroup(
... "eg",
... [
... ValueError(1),
... TypeError(2),
... OSError(3),
... ExceptionGroup(
... "nested",
... [OSError(4), TypeError(5), ValueError(6)])])
... [OSError(4), TypeError(5), ValueError(6)])
... ]
... )
... except *ValueError as e:
... print(f'*ValueError: {e!r}')
... raise e
@ -805,7 +826,6 @@ likely be lost:
>>> # destroyed after the ``except*`` clause.
>>> eg.foo
'foo'
>>>
Forbidden Combinations