Skip to content

Commit

Permalink
Merge pull request #896 from asottile/timeout-error-readme
Browse files Browse the repository at this point in the history
document TimeoutError rewrites
  • Loading branch information
asottile authored Sep 23, 2023
2 parents 19b1966 + 062aaf6 commit 34de3a0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,30 @@ Note that `if` blocks without an `else` will not be rewritten as it could introd
handle_error()
```

### `TimeoutError` aliases

Availability:
- `--py310-plus` for `socket.timeout`
- `--py311-plus` for `asyncio.Timeout`

```diff

def throw(a):
if a:
- raise asyncio.TimeoutError('boom')
+ raise TimeoutError('boom')
else:
- raise socket.timeout('boom')
+ raise TimeoutError('boom')

def catch(a):
try:
throw(a)
- except (asyncio.TimeoutError, socket.timeout):
+ except TimeoutError:
handle_error()
```

### `typing.Text` str alias

```diff
Expand Down

0 comments on commit 34de3a0

Please sign in to comment.