---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
PLW3301 [*] Nested `min` calls can be flattened
 --> nested_min_max.py:2:1
  |
1 | min(1, 2, 3)
2 | min(1, min(2, 3))
  | ^^^^^^^^^^^^^^^^^
3 | min(1, min(2, min(3, 4)))
4 | min(1, foo("a", "b"), min(3, 4))
  |
help: Flatten nested `min` calls
  |
1 | min(1, 2, 3)
  - min(1, min(2, 3))
2 + min(1, 2, 3)
3 | min(1, min(2, min(3, 4)))
  |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
 --> nested_min_max.py:3:1
  |
1 | min(1, 2, 3)
2 | min(1, min(2, 3))
3 | min(1, min(2, min(3, 4)))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
4 | min(1, foo("a", "b"), min(3, 4))
5 | min(1, max(2, 3))
  |
help: Flatten nested `min` calls
  |
2 | min(1, min(2, 3))
  - min(1, min(2, min(3, 4)))
3 + min(1, 2, 3, 4)
4 | min(1, foo("a", "b"), min(3, 4))
  |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
 --> nested_min_max.py:3:8
  |
1 | min(1, 2, 3)
2 | min(1, min(2, 3))
3 | min(1, min(2, min(3, 4)))
  |        ^^^^^^^^^^^^^^^^^
4 | min(1, foo("a", "b"), min(3, 4))
5 | min(1, max(2, 3))
  |
help: Flatten nested `min` calls
  |
2 | min(1, min(2, 3))
  - min(1, min(2, min(3, 4)))
3 + min(1, min(2, 3, 4))
4 | min(1, foo("a", "b"), min(3, 4))
  |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
 --> nested_min_max.py:4:1
  |
2 | min(1, min(2, 3))
3 | min(1, min(2, min(3, 4)))
4 | min(1, foo("a", "b"), min(3, 4))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 | min(1, max(2, 3))
6 | max(1, 2, 3)
  |
help: Flatten nested `min` calls
  |
3 | min(1, min(2, min(3, 4)))
  - min(1, foo("a", "b"), min(3, 4))
4 + min(1, foo("a", "b"), 3, 4)
5 | min(1, max(2, 3))
  |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
 --> nested_min_max.py:7:1
  |
5 | min(1, max(2, 3))
6 | max(1, 2, 3)
7 | max(1, max(2, 3))
  | ^^^^^^^^^^^^^^^^^
8 | max(1, max(2, max(3, 4)))
9 | max(1, foo("a", "b"), max(3, 4))
  |
help: Flatten nested `max` calls
  |
6 | max(1, 2, 3)
  - max(1, max(2, 3))
7 + max(1, 2, 3)
8 | max(1, max(2, max(3, 4)))
  |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
 --> nested_min_max.py:8:1
  |
6 | max(1, 2, 3)
7 | max(1, max(2, 3))
8 | max(1, max(2, max(3, 4)))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
9 | max(1, foo("a", "b"), max(3, 4))
  |
help: Flatten nested `max` calls
  |
7 | max(1, max(2, 3))
  - max(1, max(2, max(3, 4)))
8 + max(1, 2, 3, 4)
9 | max(1, foo("a", "b"), max(3, 4))
  |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
 --> nested_min_max.py:8:8
  |
6 | max(1, 2, 3)
7 | max(1, max(2, 3))
8 | max(1, max(2, max(3, 4)))
  |        ^^^^^^^^^^^^^^^^^
9 | max(1, foo("a", "b"), max(3, 4))
  |
help: Flatten nested `max` calls
  |
7 | max(1, max(2, 3))
  - max(1, max(2, max(3, 4)))
8 + max(1, max(2, 3, 4))
9 | max(1, foo("a", "b"), max(3, 4))
  |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
  --> nested_min_max.py:9:1
   |
 7 | max(1, max(2, 3))
 8 | max(1, max(2, max(3, 4)))
 9 | max(1, foo("a", "b"), max(3, 4))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 |
11 | # These should not trigger; we do not flag cases with keyword args.
   |
help: Flatten nested `max` calls
   |
8  | max(1, max(2, max(3, 4)))
   - max(1, foo("a", "b"), max(3, 4))
9  + max(1, foo("a", "b"), 3, 4)
10 |
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
  --> nested_min_max.py:15:1
   |
13 | min(1, min(2, 3, key=test))
14 | # This will still trigger, to merge the calls without keyword args.
15 | min(1, min(2, 3, key=test), min(4, 5))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 |
17 | # The fix is already unsafe, so deleting comments is okay.
   |
help: Flatten nested `min` calls
   |
14 | # This will still trigger, to merge the calls without keyword args.
   - min(1, min(2, 3, key=test), min(4, 5))
15 + min(1, min(2, 3, key=test), 4, 5)
16 |
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
  --> nested_min_max.py:18:1
   |
17 |   # The fix is already unsafe, so deleting comments is okay.
18 | / min(
19 | |     1,  # This is a comment.
20 | |     min(2, 3),
21 | | )
   | |_^
22 |
23 |   # Handle iterable expressions.
   |
help: Flatten nested `min` calls
   |
17 | # The fix is already unsafe, so deleting comments is okay.
   - min(
   -     1,  # This is a comment.
   -     min(2, 3),
   - )
18 + min(1, 2, 3)
19 |
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
  --> nested_min_max.py:24:1
   |
23 | # Handle iterable expressions.
24 | min(1, min(a))
   | ^^^^^^^^^^^^^^
25 | min(1, min(i for i in range(10)))
26 | max(1, max(a))
   |
help: Flatten nested `min` calls
   |
23 | # Handle iterable expressions.
   - min(1, min(a))
24 + min(1, *a)
25 | min(1, min(i for i in range(10)))
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
  --> nested_min_max.py:25:1
   |
23 | # Handle iterable expressions.
24 | min(1, min(a))
25 | min(1, min(i for i in range(10)))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26 | max(1, max(a))
27 | max(1, max(i for i in range(10)))
   |
help: Flatten nested `min` calls
   |
24 | min(1, min(a))
   - min(1, min(i for i in range(10)))
25 + min(1, *(i for i in range(10)))
26 | max(1, max(a))
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
  --> nested_min_max.py:26:1
   |
24 | min(1, min(a))
25 | min(1, min(i for i in range(10)))
26 | max(1, max(a))
   | ^^^^^^^^^^^^^^
27 | max(1, max(i for i in range(10)))
   |
help: Flatten nested `max` calls
   |
25 | min(1, min(i for i in range(10)))
   - max(1, max(a))
26 + max(1, *a)
27 | max(1, max(i for i in range(10)))
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
  --> nested_min_max.py:27:1
   |
25 | min(1, min(i for i in range(10)))
26 | max(1, max(a))
27 | max(1, max(i for i in range(10)))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28 |
29 | tuples_list = [
   |
help: Flatten nested `max` calls
   |
26 | max(1, max(a))
   - max(1, max(i for i in range(10)))
27 + max(1, *(i for i in range(10)))
28 |
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
  --> nested_min_max.py:41:1
   |
40 | # Starred argument should be copied as it is.
41 | max(1, max(*a))
   | ^^^^^^^^^^^^^^^
42 |
43 | import builtins
   |
help: Flatten nested `max` calls
   |
40 | # Starred argument should be copied as it is.
   - max(1, max(*a))
41 + max(1, *a)
42 |
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `min` calls can be flattened
  --> nested_min_max.py:44:1
   |
43 | import builtins
44 | builtins.min(1, min(2, 3))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Flatten nested `min` calls
   |
43 | import builtins
   - builtins.min(1, min(2, 3))
44 + builtins.min(1, 2, 3)
45 |
   |
note: This is an unsafe fix and may change runtime behavior

PLW3301 [*] Nested `max` calls can be flattened
  --> nested_min_max.py:48:16
   |
47 |   # PLW3301
48 |   max_word_len = max(
   |  ________________^
49 | |     max(len(word) for word in "blah blah blah".split(" ")),
50 | |     len("Done!"),
51 | | )
   | |_^
52 |
53 |   # OK
   |
help: Flatten nested `max` calls
   |
47 | # PLW3301
   - max_word_len = max(
   -     max(len(word) for word in "blah blah blah".split(" ")),
   -     len("Done!"),
   - )
48 + max_word_len = max(*(len(word) for word in "blah blah blah".split(" ")), len("Done!"))
49 |
   |
note: This is an unsafe fix and may change runtime behavior
