Skip to content

Commit 34de3a0

Browse files
authored
Merge pull request #896 from asottile/timeout-error-readme
document TimeoutError rewrites
2 parents 19b1966 + 062aaf6 commit 34de3a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,30 @@ Note that `if` blocks without an `else` will not be rewritten as it could introd
509509
handle_error()
510510
```
511511

512+
### `TimeoutError` aliases
513+
514+
Availability:
515+
- `--py310-plus` for `socket.timeout`
516+
- `--py311-plus` for `asyncio.Timeout`
517+
518+
```diff
519+
520+
def throw(a):
521+
if a:
522+
- raise asyncio.TimeoutError('boom')
523+
+ raise TimeoutError('boom')
524+
else:
525+
- raise socket.timeout('boom')
526+
+ raise TimeoutError('boom')
527+
528+
def catch(a):
529+
try:
530+
throw(a)
531+
- except (asyncio.TimeoutError, socket.timeout):
532+
+ except TimeoutError:
533+
handle_error()
534+
```
535+
512536
### `typing.Text` str alias
513537

514538
```diff

0 commit comments

Comments
 (0)