---
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
---
SIM102 [*] Use a single `if` statement instead of nested `if` statements
 --> SIM102.py:2:1
  |
1 |   # SIM102
2 | / if a:
3 | |     if b:
  | |_________^
4 |           c
  |
help: Combine `if` statements using `and`
  |
1 | # SIM102
  - if a:
  -     if b:
  -         c
2 + if a and b:
3 +     c
4 |
  |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:7:1
   |
 6 |   # SIM102
 7 | / if a:
 8 | |     if b:
 9 | |         if c:
   | |_____________^
10 |               d
   |
help: Combine `if` statements using `and`
   |
6  | # SIM102
   - if a:
   -     if b:
   -         if c:
   -             d
7  + if a and b:
8  +     if c:
9  +         d
10 |
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:8:5
   |
 6 |   # SIM102
 7 |   if a:
 8 | /     if b:
 9 | |         if c:
   | |_____________^
10 |               d
   |
help: Combine `if` statements using `and`
   |
7  | if a:
   -     if b:
   -         if c:
   -             d
8  +     if b and c:
9  +         d
10 |
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:15:1
   |
13 |   if a:
14 |       pass
15 | / elif b:
16 | |     if c:
   | |_________^
17 |           d
   |
help: Combine `if` statements using `and`
   |
14 |     pass
   - elif b:
   -     if c:
   -         d
15 + elif b and c:
16 +     d
17 |
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:20:1
   |
19 |   # SIM102
20 | / if a:
21 | |     # Unfixable due to placement of this comment.
22 | |     if b:
   | |_________^
23 |           c
   |
help: Combine `if` statements using `and`

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:26:1
   |
25 |   # SIM102
26 | / if a:
27 | |     if b:
   | |_________^
28 |           # Fixable due to placement of this comment.
29 |           c
   |
help: Combine `if` statements using `and`
   |
25 | # SIM102
   - if a:
   -     if b:
   -         # Fixable due to placement of this comment.
   -         c
26 + if a and b:
27 +     # Fixable due to placement of this comment.
28 +     c
29 |
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:51:5
   |
49 |   while x > 0:
50 |       # SIM102
51 | /     if y > 0:
52 | |         if z > 0:
   | |_________________^
53 |               """this
54 |   is valid"""
   |
help: Combine `if` statements using `and`
   |
50 |     # SIM102
   -     if y > 0:
   -         if z > 0:
   -             """this
51 +     if y > 0 and z > 0:
52 +         """this
53 | is valid"""
54 |
   -             """the indentation on
55 +         """the indentation on
56 |             this line is significant"""
57 |
   -             "this is" \
58 +         "this is" \
59 | "allowed too"
60 |
   -             ("so is"
61 +         ("so is"
62 | "this for some reason")
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:67:1
   |
66 |   # SIM102
67 | / if x > 0:
68 | |     if y > 0:
   | |_____________^
69 |           """this
70 |   is valid"""
   |
help: Combine `if` statements using `and`
   |
66 | # SIM102
   - if x > 0:
   -     if y > 0:
   -         """this
67 + if x > 0 and y > 0:
68 +     """this
69 | is valid"""
70 |
   -         """the indentation on
71 +     """the indentation on
72 |         this line is significant"""
73 |
   -         "this is" \
74 +     "this is" \
75 | "allowed too"
76 |
   -         ("so is"
77 +     ("so is"
78 | "this for some reason")
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:83:5
   |
81 |   while x > 0:
82 |       # SIM102
83 | /     if node.module:
84 | |         if node.module == "multiprocessing" or node.module.startswith(
85 | |             "multiprocessing."
86 | |         ):
   | |__________^
87 |               print("Bad module!")
   |
help: Combine `if` statements using `and`
   |
82 |     # SIM102
   -     if node.module:
   -         if node.module == "multiprocessing" or node.module.startswith(
   -             "multiprocessing."
   -         ):
   -             print("Bad module!")
83 +     if node.module and (node.module == "multiprocessing" or node.module.startswith(
84 +         "multiprocessing."
85 +     )):
86 +         print("Bad module!")
87 |
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
  --> SIM102.py:90:1
   |
89 |   # SIM102 (auto-fixable)
90 | / if node.module012345678:
91 | |     if node.module == "multiprocß9💣2ℝ" or node.module.startswith(
92 | |         "multiprocessing."
93 | |     ):
   | |______^
94 |           print("Bad module!")
   |
help: Combine `if` statements using `and`
   |
89 | # SIM102 (auto-fixable)
   - if node.module012345678:
   -     if node.module == "multiprocß9💣2ℝ" or node.module.startswith(
   -         "multiprocessing."
   -     ):
   -         print("Bad module!")
90 + if node.module012345678 and (node.module == "multiprocß9💣2ℝ" or node.module.startswith(
91 +     "multiprocessing."
92 + )):
93 +     print("Bad module!")
94 |
   |
note: This is an unsafe fix and may change runtime behavior

SIM102 Use a single `if` statement instead of nested `if` statements
   --> SIM102.py:97:1
    |
 96 |   # SIM102 (not auto-fixable)
 97 | / if node.module0123456789:
 98 | |     if node.module == "multiprocß9💣2ℝ" or node.module.startswith(
 99 | |         "multiprocessing."
100 | |     ):
    | |______^
101 |           print("Bad module!")
    |
help: Combine `if` statements using `and`

SIM102 [*] Use a single `if` statement instead of nested `if` statements
   --> SIM102.py:106:5
    |
104 |   # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161
105 |   if a:
106 | /     if b:
107 | |         if c:
    | |_____________^
108 |               print("if")
109 |   elif d:
    |
help: Combine `if` statements using `and`
    |
105 | if a:
    -     if b:
    -         if c:
    -             print("if")
106 +     if b and c:
107 +         print("if")
108 | elif d:
    |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
   --> SIM102.py:132:5
    |
130 |   if a:
131 |       # SIM 102
132 | /     if b:
133 | |         if c:
    | |_____________^
134 |               print("foo")
135 |   else:
    |
help: Combine `if` statements using `and`
    |
131 |     # SIM 102
    -     if b:
    -         if c:
    -             print("foo")
132 +     if b and c:
133 +         print("foo")
134 | else:
    |
note: This is an unsafe fix and may change runtime behavior

SIM102 [*] Use a single `if` statement instead of nested `if` statements
   --> SIM102.py:165:5
    |
163 |       if a:
164 |           pass
165 | /     elif b:
166 | |         if c:
    | |_____________^
167 |               d
    |
help: Combine `if` statements using `and`
    |
164 |         pass
    -     elif b:
    -         if c:
    -             d
165 +     elif b and c:
166 +         d
    |
note: This is an unsafe fix and may change runtime behavior
