---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
---
UP027.py:2:17: UP027 [*] Replace unpacked list comprehension with a generator expression
  |
1 | # Should change
2 | foo, bar, baz = [fn(x) for x in items]
  |                 ^^^^^^^^^^^^^^^^^^^^^^ UP027
3 | 
4 | foo, bar, baz =[fn(x) for x in items]
  |
  = help: Replace with generator expression

ℹ Safe fix
1 1 | # Should change
2   |-foo, bar, baz = [fn(x) for x in items]
  2 |+foo, bar, baz = (fn(x) for x in items)
3 3 | 
4 4 | foo, bar, baz =[fn(x) for x in items]
5 5 | 

UP027.py:4:16: UP027 [*] Replace unpacked list comprehension with a generator expression
  |
2 | foo, bar, baz = [fn(x) for x in items]
3 | 
4 | foo, bar, baz =[fn(x) for x in items]
  |                ^^^^^^^^^^^^^^^^^^^^^^ UP027
5 | 
6 | foo, bar, baz =          [fn(x) for x in items]
  |
  = help: Replace with generator expression

ℹ Safe fix
1 1 | # Should change
2 2 | foo, bar, baz = [fn(x) for x in items]
3 3 | 
4   |-foo, bar, baz =[fn(x) for x in items]
  4 |+foo, bar, baz =(fn(x) for x in items)
5 5 | 
6 6 | foo, bar, baz =          [fn(x) for x in items]
7 7 | 

UP027.py:6:26: UP027 [*] Replace unpacked list comprehension with a generator expression
  |
4 | foo, bar, baz =[fn(x) for x in items]
5 | 
6 | foo, bar, baz =          [fn(x) for x in items]
  |                          ^^^^^^^^^^^^^^^^^^^^^^ UP027
7 | 
8 | foo, bar, baz = [[i for i in fn(x)] for x in items]
  |
  = help: Replace with generator expression

ℹ Safe fix
3 3 | 
4 4 | foo, bar, baz =[fn(x) for x in items]
5 5 | 
6   |-foo, bar, baz =          [fn(x) for x in items]
  6 |+foo, bar, baz =          (fn(x) for x in items)
7 7 | 
8 8 | foo, bar, baz = [[i for i in fn(x)] for x in items]
9 9 | 

UP027.py:8:17: UP027 [*] Replace unpacked list comprehension with a generator expression
   |
 6 | foo, bar, baz =          [fn(x) for x in items]
 7 | 
 8 | foo, bar, baz = [[i for i in fn(x)] for x in items]
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP027
 9 | 
10 | foo, bar, baz = [
   |
   = help: Replace with generator expression

ℹ Safe fix
5 5 | 
6 6 | foo, bar, baz =          [fn(x) for x in items]
7 7 | 
8   |-foo, bar, baz = [[i for i in fn(x)] for x in items]
  8 |+foo, bar, baz = ([i for i in fn(x)] for x in items)
9 9 | 
10 10 | foo, bar, baz = [
11 11 |     fn(x)

UP027.py:10:17: UP027 [*] Replace unpacked list comprehension with a generator expression
   |
 8 |   foo, bar, baz = [[i for i in fn(x)] for x in items]
 9 |   
10 |   foo, bar, baz = [
   |  _________________^
11 | |     fn(x)
12 | |     for x in items
13 | | ]
   | |_^ UP027
14 |   
15 |   # Should not change
   |
   = help: Replace with generator expression

ℹ Safe fix
7  7  | 
8  8  | foo, bar, baz = [[i for i in fn(x)] for x in items]
9  9  | 
10    |-foo, bar, baz = [
   10 |+foo, bar, baz = (
11 11 |     fn(x)
12 12 |     for x in items
13    |-]
   13 |+)
14 14 | 
15 15 | # Should not change
16 16 | foo = [fn(x) for x in items]
