---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
nested_min_max.py:2:1: PLW3301 [*] Nested `min` calls can be flattened
  |
1 | min(1, 2, 3)
2 | min(1, min(2, 3))
  | ^^^^^^^^^^^^^^^^^ PLW3301
3 | min(1, min(2, min(3, 4)))
4 | min(1, foo("a", "b"), min(3, 4))
  |
  = help: Flatten nested `min` calls

ℹ Unsafe fix
1 1 | min(1, 2, 3)
2   |-min(1, min(2, 3))
  2 |+min(1, 2, 3)
3 3 | min(1, min(2, min(3, 4)))
4 4 | min(1, foo("a", "b"), min(3, 4))
5 5 | min(1, max(2, 3))

nested_min_max.py:3:1: PLW3301 [*] Nested `min` calls can be flattened
  |
1 | min(1, 2, 3)
2 | min(1, min(2, 3))
3 | min(1, min(2, min(3, 4)))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
4 | min(1, foo("a", "b"), min(3, 4))
5 | min(1, max(2, 3))
  |
  = help: Flatten nested `min` calls

ℹ Unsafe fix
1 1 | min(1, 2, 3)
2 2 | min(1, min(2, 3))
3   |-min(1, min(2, min(3, 4)))
  3 |+min(1, 2, 3, 4)
4 4 | min(1, foo("a", "b"), min(3, 4))
5 5 | min(1, max(2, 3))
6 6 | max(1, 2, 3)

nested_min_max.py:3:8: PLW3301 [*] Nested `min` calls can be flattened
  |
1 | min(1, 2, 3)
2 | min(1, min(2, 3))
3 | min(1, min(2, min(3, 4)))
  |        ^^^^^^^^^^^^^^^^^ PLW3301
4 | min(1, foo("a", "b"), min(3, 4))
5 | min(1, max(2, 3))
  |
  = help: Flatten nested `min` calls

ℹ Unsafe fix
1 1 | min(1, 2, 3)
2 2 | min(1, min(2, 3))
3   |-min(1, min(2, min(3, 4)))
  3 |+min(1, min(2, 3, 4))
4 4 | min(1, foo("a", "b"), min(3, 4))
5 5 | min(1, max(2, 3))
6 6 | max(1, 2, 3)

nested_min_max.py:4:1: PLW3301 [*] Nested `min` calls can be flattened
  |
2 | min(1, min(2, 3))
3 | min(1, min(2, min(3, 4)))
4 | min(1, foo("a", "b"), min(3, 4))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
5 | min(1, max(2, 3))
6 | max(1, 2, 3)
  |
  = help: Flatten nested `min` calls

ℹ Unsafe fix
1 1 | min(1, 2, 3)
2 2 | min(1, min(2, 3))
3 3 | min(1, min(2, min(3, 4)))
4   |-min(1, foo("a", "b"), min(3, 4))
  4 |+min(1, foo("a", "b"), 3, 4)
5 5 | min(1, max(2, 3))
6 6 | max(1, 2, 3)
7 7 | max(1, max(2, 3))

nested_min_max.py:7:1: PLW3301 [*] Nested `max` calls can be flattened
  |
5 | min(1, max(2, 3))
6 | max(1, 2, 3)
7 | max(1, max(2, 3))
  | ^^^^^^^^^^^^^^^^^ PLW3301
8 | max(1, max(2, max(3, 4)))
9 | max(1, foo("a", "b"), max(3, 4))
  |
  = help: Flatten nested `max` calls

ℹ Unsafe fix
4 4 | min(1, foo("a", "b"), min(3, 4))
5 5 | min(1, max(2, 3))
6 6 | max(1, 2, 3)
7   |-max(1, max(2, 3))
  7 |+max(1, 2, 3)
8 8 | max(1, max(2, max(3, 4)))
9 9 | max(1, foo("a", "b"), max(3, 4))
10 10 | 

nested_min_max.py:8:1: PLW3301 [*] Nested `max` calls can be flattened
  |
6 | max(1, 2, 3)
7 | max(1, max(2, 3))
8 | max(1, max(2, max(3, 4)))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
9 | max(1, foo("a", "b"), max(3, 4))
  |
  = help: Flatten nested `max` calls

ℹ Unsafe fix
5 5 | min(1, max(2, 3))
6 6 | max(1, 2, 3)
7 7 | max(1, max(2, 3))
8   |-max(1, max(2, max(3, 4)))
  8 |+max(1, 2, 3, 4)
9 9 | max(1, foo("a", "b"), max(3, 4))
10 10 | 
11 11 | # These should not trigger; we do not flag cases with keyword args.

nested_min_max.py:8:8: PLW3301 [*] Nested `max` calls can be flattened
  |
6 | max(1, 2, 3)
7 | max(1, max(2, 3))
8 | max(1, max(2, max(3, 4)))
  |        ^^^^^^^^^^^^^^^^^ PLW3301
9 | max(1, foo("a", "b"), max(3, 4))
  |
  = help: Flatten nested `max` calls

ℹ Unsafe fix
5 5 | min(1, max(2, 3))
6 6 | max(1, 2, 3)
7 7 | max(1, max(2, 3))
8   |-max(1, max(2, max(3, 4)))
  8 |+max(1, max(2, 3, 4))
9 9 | max(1, foo("a", "b"), max(3, 4))
10 10 | 
11 11 | # These should not trigger; we do not flag cases with keyword args.

nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened
   |
 7 | max(1, max(2, 3))
 8 | max(1, max(2, max(3, 4)))
 9 | max(1, foo("a", "b"), max(3, 4))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
10 | 
11 | # These should not trigger; we do not flag cases with keyword args.
   |
   = help: Flatten nested `max` calls

ℹ Unsafe fix
6  6  | max(1, 2, 3)
7  7  | max(1, max(2, 3))
8  8  | max(1, max(2, max(3, 4)))
9     |-max(1, foo("a", "b"), max(3, 4))
   9  |+max(1, foo("a", "b"), 3, 4)
10 10 | 
11 11 | # These should not trigger; we do not flag cases with keyword args.
12 12 | min(1, min(2, 3), key=test)

nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened
   |
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))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
16 | 
17 | # Don't provide a fix if there are comments within the call.
   |
   = help: Flatten nested `min` calls

ℹ Unsafe fix
12 12 | min(1, min(2, 3), key=test)
13 13 | min(1, min(2, 3, key=test))
14 14 | # This will still trigger, to merge the calls without keyword args.
15    |-min(1, min(2, 3, key=test), min(4, 5))
   15 |+min(1, min(2, 3, key=test), 4, 5)
16 16 | 
17 17 | # Don't provide a fix if there are comments within the call.
18 18 | min(

nested_min_max.py:18:1: PLW3301 Nested `min` calls can be flattened
   |
17 |   # Don't provide a fix if there are comments within the call.
18 | / min(
19 | |     1,  # This is a comment.
20 | |     min(2, 3),
21 | | )
   | |_^ PLW3301
22 |   
23 |   # Handle iterable expressions.
   |
   = help: Flatten nested `min` calls

nested_min_max.py:24:1: PLW3301 [*] Nested `min` calls can be flattened
   |
23 | # Handle iterable expressions.
24 | min(1, min(a))
   | ^^^^^^^^^^^^^^ PLW3301
25 | min(1, min(i for i in range(10)))
26 | max(1, max(a))
   |
   = help: Flatten nested `min` calls

ℹ Unsafe fix
21 21 | )
22 22 | 
23 23 | # Handle iterable expressions.
24    |-min(1, min(a))
   24 |+min(1, *a)
25 25 | min(1, min(i for i in range(10)))
26 26 | max(1, max(a))
27 27 | max(1, max(i for i in range(10)))

nested_min_max.py:25:1: PLW3301 [*] Nested `min` calls can be flattened
   |
23 | # Handle iterable expressions.
24 | min(1, min(a))
25 | min(1, min(i for i in range(10)))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
26 | max(1, max(a))
27 | max(1, max(i for i in range(10)))
   |
   = help: Flatten nested `min` calls

ℹ Unsafe fix
22 22 | 
23 23 | # Handle iterable expressions.
24 24 | min(1, min(a))
25    |-min(1, min(i for i in range(10)))
   25 |+min(1, *(i for i in range(10)))
26 26 | max(1, max(a))
27 27 | max(1, max(i for i in range(10)))
28 28 | 

nested_min_max.py:26:1: PLW3301 [*] Nested `max` calls can be flattened
   |
24 | min(1, min(a))
25 | min(1, min(i for i in range(10)))
26 | max(1, max(a))
   | ^^^^^^^^^^^^^^ PLW3301
27 | max(1, max(i for i in range(10)))
   |
   = help: Flatten nested `max` calls

ℹ Unsafe fix
23 23 | # Handle iterable expressions.
24 24 | min(1, min(a))
25 25 | min(1, min(i for i in range(10)))
26    |-max(1, max(a))
   26 |+max(1, *a)
27 27 | max(1, max(i for i in range(10)))
28 28 | 
29 29 | tuples_list = [

nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened
   |
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)))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
28 | 
29 | tuples_list = [
   |
   = help: Flatten nested `max` calls

ℹ Unsafe fix
24 24 | min(1, min(a))
25 25 | min(1, min(i for i in range(10)))
26 26 | max(1, max(a))
27    |-max(1, max(i for i in range(10)))
   27 |+max(1, *(i for i in range(10)))
28 28 | 
29 29 | tuples_list = [
30 30 |     (1, 2),

nested_min_max.py:41:1: PLW3301 [*] Nested `max` calls can be flattened
   |
40 | # Starred argument should be copied as it is.
41 | max(1, max(*a))
   | ^^^^^^^^^^^^^^^ PLW3301
42 | 
43 | import builtins
   |
   = help: Flatten nested `max` calls

ℹ Unsafe fix
38 38 | max(max(tuples_list))
39 39 | 
40 40 | # Starred argument should be copied as it is.
41    |-max(1, max(*a))
   41 |+max(1, *a)
42 42 | 
43 43 | import builtins
44 44 | builtins.min(1, min(2, 3))

nested_min_max.py:44:1: PLW3301 [*] Nested `min` calls can be flattened
   |
43 | import builtins
44 | builtins.min(1, min(2, 3))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301
   |
   = help: Flatten nested `min` calls

ℹ Unsafe fix
41 41 | max(1, max(*a))
42 42 | 
43 43 | import builtins
44    |-builtins.min(1, min(2, 3))
   44 |+builtins.min(1, 2, 3)
