---
source: crates/ruff_linter/src/rules/refurb/mod.rs
---
FURB131.py:11:1: FURB131 [*] Prefer `clear` over deleting a full slice
   |
10 | # FURB131
11 | del nums[:]
   | ^^^^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
8  8  | # these should match
9  9  | 
10 10 | # FURB131
11    |-del nums[:]
   11 |+nums.clear()
12 12 | 
13 13 | 
14 14 | # FURB131

FURB131.py:15:1: FURB131 [*] Prefer `clear` over deleting a full slice
   |
14 | # FURB131
15 | del names[:]
   | ^^^^^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
12 12 | 
13 13 | 
14 14 | # FURB131
15    |-del names[:]
   15 |+names.clear()
16 16 | 
17 17 | 
18 18 | # FURB131

FURB131.py:19:1: FURB131 Prefer `clear` over deleting a full slice
   |
18 | # FURB131
19 | del x, nums[:]
   | ^^^^^^^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

FURB131.py:23:1: FURB131 Prefer `clear` over deleting a full slice
   |
22 | # FURB131
23 | del y, names[:], x
   | ^^^^^^^^^^^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

FURB131.py:28:5: FURB131 [*] Prefer `clear` over deleting a full slice
   |
26 | def yes_one(x: list[int]):
27 |     # FURB131
28 |     del x[:]
   |     ^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
25 25 | 
26 26 | def yes_one(x: list[int]):
27 27 |     # FURB131
28    |-    del x[:]
   28 |+    x.clear()
29 29 | 
30 30 | 
31 31 | def yes_two(x: dict[int, str]):

FURB131.py:33:5: FURB131 [*] Prefer `clear` over deleting a full slice
   |
31 | def yes_two(x: dict[int, str]):
32 |     # FURB131
33 |     del x[:]
   |     ^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
30 30 | 
31 31 | def yes_two(x: dict[int, str]):
32 32 |     # FURB131
33    |-    del x[:]
   33 |+    x.clear()
34 34 | 
35 35 | 
36 36 | def yes_three(x: List[int]):

FURB131.py:38:5: FURB131 [*] Prefer `clear` over deleting a full slice
   |
36 | def yes_three(x: List[int]):
37 |     # FURB131
38 |     del x[:]
   |     ^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
35 35 | 
36 36 | def yes_three(x: List[int]):
37 37 |     # FURB131
38    |-    del x[:]
   38 |+    x.clear()
39 39 | 
40 40 | 
41 41 | def yes_four(x: Dict[int, str]):

FURB131.py:43:5: FURB131 [*] Prefer `clear` over deleting a full slice
   |
41 | def yes_four(x: Dict[int, str]):
42 |     # FURB131
43 |     del x[:]
   |     ^^^^^^^^ FURB131
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
40 40 | 
41 41 | def yes_four(x: Dict[int, str]):
42 42 |     # FURB131
43    |-    del x[:]
   43 |+    x.clear()
44 44 | 
45 45 | 
46 46 | def yes_five(x: Dict[int, str]):

FURB131.py:48:5: FURB131 [*] Prefer `clear` over deleting a full slice
   |
46 | def yes_five(x: Dict[int, str]):
47 |     # FURB131
48 |     del x[:]
   |     ^^^^^^^^ FURB131
49 | 
50 |     x = 1
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
45 45 | 
46 46 | def yes_five(x: Dict[int, str]):
47 47 |     # FURB131
48    |-    del x[:]
   48 |+    x.clear()
49 49 | 
50 50 |     x = 1
51 51 | 

FURB131.py:58:1: FURB131 [*] Prefer `clear` over deleting a full slice
   |
56 | sneaky = SneakyList()
57 | # FURB131
58 | del sneaky[:]
   | ^^^^^^^^^^^^^ FURB131
59 | 
60 | # these should not
   |
   = help: Replace with `clear()`

ℹ Unsafe fix
55 55 | 
56 56 | sneaky = SneakyList()
57 57 | # FURB131
58    |-del sneaky[:]
   58 |+sneaky.clear()
59 59 | 
60 60 | # these should not
61 61 |
