---
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
---
SIM111.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop
  |
1 |   def f():
2 |       # SIM110
3 |       for x in iterable:
  |  _____^
4 | |         if check(x):
5 | |             return True
6 | |     return False
  | |________________^ SIM110
  |
  = help: Replace with `return any(check(x) for x in iterable)`

ℹ Unsafe fix
1 1 | def f():
2 2 |     # SIM110
3   |-    for x in iterable:
4   |-        if check(x):
5   |-            return True
6   |-    return False
  3 |+    return any(check(x) for x in iterable)
7 4 | 
8 5 | 
9 6 | def f():

SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop
   |
23 |   def f():
24 |       # SIM111
25 |       for x in iterable:
   |  _____^
26 | |         if check(x):
27 | |             return False
28 | |     return True
   | |_______________^ SIM110
   |
   = help: Replace with `return all(not check(x) for x in iterable)`

ℹ Unsafe fix
22 22 | 
23 23 | def f():
24 24 |     # SIM111
25    |-    for x in iterable:
26    |-        if check(x):
27    |-            return False
28    |-    return True
   25 |+    return all(not check(x) for x in iterable)
29 26 | 
30 27 | 
31 28 | def f():

SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop
   |
31 |   def f():
32 |       # SIM111
33 |       for x in iterable:
   |  _____^
34 | |         if not x.is_empty():
35 | |             return False
36 | |     return True
   | |_______________^ SIM110
   |
   = help: Replace with `return all(x.is_empty() for x in iterable)`

ℹ Unsafe fix
30 30 | 
31 31 | def f():
32 32 |     # SIM111
33    |-    for x in iterable:
34    |-        if not x.is_empty():
35    |-            return False
36    |-    return True
   33 |+    return all(x.is_empty() for x in iterable)
37 34 | 
38 35 | 
39 36 | def f():

SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop
   |
53 |   def f():
54 |       # SIM110
55 |       for x in iterable:
   |  _____^
56 | |         if check(x):
57 | |             return True
58 | |     else:
59 | |         return False
   | |____________________^ SIM110
   |
   = help: Replace with `return any(check(x) for x in iterable)`

ℹ Unsafe fix
52 52 | 
53 53 | def f():
54 54 |     # SIM110
55    |-    for x in iterable:
56    |-        if check(x):
57    |-            return True
58    |-    else:
59    |-        return False
   55 |+    return any(check(x) for x in iterable)
60 56 | 
61 57 | 
62 58 | def f():

SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop
   |
62 |   def f():
63 |       # SIM111
64 |       for x in iterable:
   |  _____^
65 | |         if check(x):
66 | |             return False
67 | |     else:
68 | |         return True
   | |___________________^ SIM110
   |
   = help: Replace with `return all(not check(x) for x in iterable)`

ℹ Unsafe fix
61 61 | 
62 62 | def f():
63 63 |     # SIM111
64    |-    for x in iterable:
65    |-        if check(x):
66    |-            return False
67    |-    else:
68    |-        return True
   64 |+    return all(not check(x) for x in iterable)
69 65 | 
70 66 | 
71 67 | def f():

SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop
   |
71 |   def f():
72 |       # SIM110
73 |       for x in iterable:
   |  _____^
74 | |         if check(x):
75 | |             return True
76 | |     else:
77 | |         return False
   | |____________________^ SIM110
78 |       return True
   |
   = help: Replace with `return any(check(x) for x in iterable)`

ℹ Unsafe fix
70 70 | 
71 71 | def f():
72 72 |     # SIM110
73    |-    for x in iterable:
74    |-        if check(x):
75    |-            return True
76    |-    else:
77    |-        return False
   73 |+    return any(check(x) for x in iterable)
78 74 |     return True
79 75 | 
80 76 | 

SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop
   |
81 |   def f():
82 |       # SIM111
83 |       for x in iterable:
   |  _____^
84 | |         if check(x):
85 | |             return False
86 | |     else:
87 | |         return True
   | |___________________^ SIM110
88 |       return False
   |
   = help: Replace with `return all(not check(x) for x in iterable)`

ℹ Unsafe fix
80 80 | 
81 81 | def f():
82 82 |     # SIM111
83    |-    for x in iterable:
84    |-        if check(x):
85    |-            return False
86    |-    else:
87    |-        return True
   83 |+    return all(not check(x) for x in iterable)
88 84 |     return False
89 85 | 
90 86 | 

SIM111.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop
    |
122 |           pass
123 |   
124 |       for x in iterable:
    |  _____^
125 | |         if check(x):
126 | |             return True
127 | |     return False
    | |________________^ SIM110
    |
    = help: Replace with `return any(check(x) for x in iterable)`

SIM111.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead of `for` loop
    |
132 |           pass
133 |   
134 |       for x in iterable:
    |  _____^
135 | |         if check(x):
136 | |             return False
137 | |     return True
    | |_______________^ SIM110
    |
    = help: Replace with `return all(not check(x) for x in iterable)`

SIM111.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop
    |
143 |       # SIM110
144 |       for x in iterable:
    |  _____^
145 | |         if check(x):
146 | |             return True
147 | |     return False
    | |________________^ SIM110
    |
    = help: Replace with `return any(check(x) for x in iterable)`

ℹ Unsafe fix
141 141 |     x = 1
142 142 | 
143 143 |     # SIM110
144     |-    for x in iterable:
145     |-        if check(x):
146     |-            return True
147     |-    return False
    144 |+    return any(check(x) for x in iterable)
148 145 | 
149 146 | 
150 147 | def f():

SIM111.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop
    |
153 |       # SIM111
154 |       for x in iterable:
    |  _____^
155 | |         if check(x):
156 | |             return False
157 | |     return True
    | |_______________^ SIM110
    |
    = help: Replace with `return all(not check(x) for x in iterable)`

ℹ Unsafe fix
151 151 |     x = 1
152 152 | 
153 153 |     # SIM111
154     |-    for x in iterable:
155     |-        if check(x):
156     |-            return False
157     |-    return True
    154 |+    return all(not check(x) for x in iterable)
158 155 | 
159 156 | 
160 157 | def f():

SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead of `for` loop
    |
160 |   def f():
161 |       # SIM111
162 |       for x in iterable:
    |  _____^
163 | |         if x not in y:
164 | |             return False
165 | |     return True
    | |_______________^ SIM110
    |
    = help: Replace with `return all(x in y for x in iterable)`

ℹ Unsafe fix
159 159 | 
160 160 | def f():
161 161 |     # SIM111
162     |-    for x in iterable:
163     |-        if x not in y:
164     |-            return False
165     |-    return True
    162 |+    return all(x in y for x in iterable)
166 163 | 
167 164 | 
168 165 | def f():

SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead of `for` loop
    |
168 |   def f():
169 |       # SIM111
170 |       for x in iterable:
    |  _____^
171 | |         if x > y:
172 | |             return False
173 | |     return True
    | |_______________^ SIM110
    |
    = help: Replace with `return all(x <= y for x in iterable)`

ℹ Unsafe fix
167 167 | 
168 168 | def f():
169 169 |     # SIM111
170     |-    for x in iterable:
171     |-        if x > y:
172     |-            return False
173     |-    return True
    170 |+    return all(x <= y for x in iterable)
174 171 | 
175 172 | 
176 173 | def f():

SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` instead of `for` loop
    |
176 |   def f():
177 |       # SIM111
178 |       for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9":
    |  _____^
179 | |         if x.isdigit():
180 | |             return False
181 | |     return True
    | |_______________^ SIM110
    |
    = help: Replace with `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")`

ℹ Unsafe fix
175 175 | 
176 176 | def f():
177 177 |     # SIM111
178     |-    for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9":
179     |-        if x.isdigit():
180     |-            return False
181     |-    return True
    178 |+    return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")
182 179 | 
183 180 | 
184 181 | def f():


