---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
snapshot_kind: text
---
UP041.py:5:8: UP041 [*] Replace aliased errors with `TimeoutError`
  |
3 | try:
4 |     pass
5 | except asyncio.TimeoutError:
  |        ^^^^^^^^^^^^^^^^^^^^ UP041
6 |     pass
  |
  = help: Replace `asyncio.TimeoutError` with builtin `TimeoutError`

ℹ Safe fix
2 2 | # These should be fixed
3 3 | try:
4 4 |     pass
5   |-except asyncio.TimeoutError:
  5 |+except TimeoutError:
6 6 |     pass
7 7 | 
8 8 | try:

UP041.py:10:8: UP041 [*] Replace aliased errors with `TimeoutError`
   |
 8 | try:
 9 |     pass
10 | except socket.timeout:
   |        ^^^^^^^^^^^^^^ UP041
11 |     pass
   |
   = help: Replace `socket.timeout` with builtin `TimeoutError`

ℹ Safe fix
7  7  | 
8  8  | try:
9  9  |     pass
10    |-except socket.timeout:
   10 |+except TimeoutError:
11 11 |     pass
12 12 | 
13 13 | # Should NOT be in parentheses when replaced

UP041.py:17:8: UP041 [*] Replace aliased errors with `TimeoutError`
   |
15 | try:
16 |     pass
17 | except (asyncio.TimeoutError,):
   |        ^^^^^^^^^^^^^^^^^^^^^^^ UP041
18 |     pass
   |
   = help: Replace with builtin `TimeoutError`

ℹ Safe fix
14 14 | 
15 15 | try:
16 16 |     pass
17    |-except (asyncio.TimeoutError,):
   17 |+except TimeoutError:
18 18 |     pass
19 19 | 
20 20 | try:

UP041.py:22:8: UP041 [*] Replace aliased errors with `TimeoutError`
   |
20 | try:
21 |     pass
22 | except (socket.timeout,):
   |        ^^^^^^^^^^^^^^^^^ UP041
23 |     pass
   |
   = help: Replace with builtin `TimeoutError`

ℹ Safe fix
19 19 | 
20 20 | try:
21 21 |     pass
22    |-except (socket.timeout,):
   22 |+except TimeoutError:
23 23 |     pass
24 24 | 
25 25 | try:

UP041.py:27:8: UP041 [*] Replace aliased errors with `TimeoutError`
   |
25 | try:
26 |     pass
27 | except (asyncio.TimeoutError, socket.timeout,):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041
28 |     pass
   |
   = help: Replace with builtin `TimeoutError`

ℹ Safe fix
24 24 | 
25 25 | try:
26 26 |     pass
27    |-except (asyncio.TimeoutError, socket.timeout,):
   27 |+except TimeoutError:
28 28 |     pass
29 29 | 
30 30 | # Should be kept in parentheses (because multiple)

UP041.py:34:8: UP041 [*] Replace aliased errors with `TimeoutError`
   |
32 | try:
33 |     pass
34 | except (asyncio.TimeoutError, socket.timeout, KeyError, TimeoutError):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041
35 |     pass
   |
   = help: Replace with builtin `TimeoutError`

ℹ Safe fix
31 31 | 
32 32 | try:
33 33 |     pass
34    |-except (asyncio.TimeoutError, socket.timeout, KeyError, TimeoutError):
   34 |+except (KeyError, TimeoutError):
35 35 |     pass
36 36 | 
37 37 | # First should change, second should not

UP041.py:42:8: UP041 [*] Replace aliased errors with `TimeoutError`
   |
40 | try:
41 |     pass
42 | except (asyncio.TimeoutError, error):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041
43 |     pass
   |
   = help: Replace with builtin `TimeoutError`

ℹ Safe fix
39 39 | from .mmap import error
40 40 | try:
41 41 |     pass
42    |-except (asyncio.TimeoutError, error):
   42 |+except (TimeoutError, error):
43 43 |     pass
44 44 | 
45 45 | # These should not change
