Debian Codegraph @

tests/data/cases/remove_parens_from_lhs.py

raw
1 # Remove unnecessary parentheses from LHS of assignments
2
3
4 def a():
5 return [1, 2, 3]
6
7
8 # Single variable with unnecessary parentheses
9 (b) = a()[0]
10
11 # Tuple unpacking with unnecessary parentheses
12 (c, *_) = a()
13
14 # These should not be changed - parentheses are necessary
15 (d,) = a() # single-element tuple
16 e = (1 + 2) * 3 # RHS has precedence needs
17
18 # output
19
20 # Remove unnecessary parentheses from LHS of assignments
21
22
23 def a():
24 return [1, 2, 3]
25
26
27 # Single variable with unnecessary parentheses
28 b = a()[0]
29
30 # Tuple unpacking with unnecessary parentheses
31 c, *_ = a()
32
33 # These should not be changed - parentheses are necessary
34 (d,) = a() # single-element tuple
35 e = (1 + 2) * 3 # RHS has precedence needs