---
source: crates/ruff_linter/src/rules/flake8_return/mod.rs
---
RET505 [*] Unnecessary `elif` after `return` statement
  --> RET505.py:8:5
   |
 6 |         a = 1
 7 |         return y
 8 |     elif z:
   |     ^^^^
 9 |         b = 2
10 |         return w
   |
help: Remove unnecessary `elif`
  |
7 |         return y
  -     elif z:
8 +     if z:
9 |         b = 2
  |

RET505 [*] Unnecessary `elif` after `return` statement
  --> RET505.py:23:5
   |
21 |             b = 2
22 |         return
23 |     elif z:
   |     ^^^^
24 |         c = 2
25 |     else:
   |
help: Remove unnecessary `elif`
   |
22 |         return
   -     elif z:
23 +     if z:
24 |         c = 2
   |

RET505 [*] Unnecessary `elif` after `return` statement
  --> RET505.py:41:5
   |
39 |         a = 1
40 |         return y
41 |     elif z:
   |     ^^^^
42 |         b = 2
43 |         return w
   |
help: Remove unnecessary `elif`
   |
40 |         return y
   -     elif z:
41 +     if z:
42 |         b = 2
   |

RET505 [*] Unnecessary `else` after `return` statement
  --> RET505.py:53:5
   |
51 |         a = 1
52 |         return y
53 |     else:
   |     ^^^^
54 |         b = 2
55 |         return z
   |
help: Remove unnecessary `else`
   |
52 |         return y
   -     else:
   -         b = 2
   -         return z
53 +     b = 2
54 +     return z
55 |
   |

RET505 [*] Unnecessary `else` after `return` statement
  --> RET505.py:64:9
   |
62 |             b = 2
63 |             return y
64 |         else:
   |         ^^^^
65 |             c = 3
66 |             return x
   |
help: Remove unnecessary `else`
   |
63 |             return y
   -         else:
   -             c = 3
   -             return x
64 +         c = 3
65 +         return x
66 |     else:
   |

RET505 [*] Unnecessary `else` after `return` statement
  --> RET505.py:79:5
   |
77 |             b = 2
78 |         return
79 |     else:
   |     ^^^^
80 |         c = 3
81 |     return
   |
help: Remove unnecessary `else`
   |
78 |         return
   -     else:
   -         c = 3
79 +     c = 3
80 |     return
   |

RET505 [*] Unnecessary `else` after `return` statement
  --> RET505.py:89:9
   |
87 |             a = 4
88 |             return
89 |         else:
   |         ^^^^
90 |             b = 2
91 |     else:
   |
help: Remove unnecessary `else`
   |
88 |             return
   -         else:
   -             b = 2
89 +         b = 2
90 |     else:
   |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:99:5
    |
 97 |     if x:  # [no-else-return]
 98 |         return True
 99 |     else:
    |     ^^^^
100 |         try:
101 |             return False
    |
help: Remove unnecessary `else`
    |
98  |         return True
    -     else:
    -         try:
    -             return False
    -         except ValueError:
    -             return None
99  +     try:
100 +         return False
101 +     except ValueError:
102 +         return None
103 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:109:5
    |
107 |     if n<2:
108 |         return n;
109 |     else:
    |     ^^^^
110 |         last = 1;
111 |         last2 = 0;
    |
help: Remove unnecessary `else`
    |
108 |         return n;
    -     else:
    -         last = 1;
    -         last2 = 0;
109 +     last = 1;
110 +     last2 = 0;
111 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:145:5
    |
143 |     if True:
144 |         return
145 |     else:
    |     ^^^^
146 |         # comment
147 |         pass
    |
help: Remove unnecessary `else`
    |
144 |         return
    -     else:
    -         # comment
    -         pass
145 +     # comment
146 +     pass
147 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:153:5
    |
151 |     if True:
152 |         return
153 |     else:  # comment
    |     ^^^^
154 |         pass
    |
help: Remove unnecessary `else`
    |
152 |         return
    -     else:  # comment
    -         pass
153 +     # comment
154 +     pass
155 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:160:5
    |
158 |     if True:
159 |         return
160 |     else\
    |     ^^^^
161 |         :\
162 |         # comment
    |
help: Remove unnecessary `else`
    |
159 |         return
    -     else\
    -         :\
    -         # comment
    -         pass
160 +     # comment
161 +     pass
162 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:169:5
    |
167 |     if True:
168 |         return
169 |     else\
    |     ^^^^
170 |         :  # comment
171 |         pass
    |
help: Remove unnecessary `else`
    |
168 |         return
    -     else\
    -         :  # comment
    -         pass
169 +     # comment
170 +     pass
171 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:177:5
    |
175 |     if True:
176 |         return
177 |     else: pass
    |     ^^^^
    |
help: Remove unnecessary `else`
    |
176 |         return
    -     else: pass
177 +     pass
178 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:183:5
    |
181 |     if True:
182 |         return
183 |     else:\
    |     ^^^^
184 |         pass
    |
help: Remove unnecessary `else`
    |
182 |         return
    -     else:\
    -         pass
183 +     pass
184 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:200:5
    |
198 | def sb(self):
199 |     if self._sb is not None: return self._sb
200 |     else: self._sb = '\033[01;%dm'; self._sa = '\033[0;0m';
    |     ^^^^
    |
help: Remove unnecessary `else`
    |
199 |     if self._sb is not None: return self._sb
    -     else: self._sb = '\033[01;%dm'; self._sa = '\033[0;0m';
200 +     self._sb = '\033[01;%dm'; self._sa = '\033[0;0m';
201 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:207:5
    |
205 |         a = 1
206 |         return y
207 |     else:
    |     ^^^^
208 |
209 |         c = 3
    |
help: Remove unnecessary `else`
    |
206 |         return y
    -     else:
207 |
    -         c = 3
    -         return z
208 +     c = 3
209 +     return z
210 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:217:5
    |
215 |         a = 1
216 |         return y
217 |     else:
    |     ^^^^
218 |         # comment
219 |         c = 3
    |
help: Remove unnecessary `else`
    |
216 |         return y
    -     else:
    -         # comment
    -         c = 3
    -         return z
217 +     # comment
218 +     c = 3
219 +     return z
220 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:227:5
    |
225 |         a = 1
226 |         return y
227 |     else:
    |     ^^^^
228 |           # comment
229 |         c = 3
    |
help: Remove unnecessary `else`
    |
226 |         return y
    -     else:
    -           # comment
    -         c = 3
    -         return z
227 +       # comment
228 +     c = 3
229 +     return z
230 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:237:5
    |
235 |         a = 1
236 |         return y
237 |     else:
    |     ^^^^
238 |   # comment
239 |         c = 3
    |
help: Remove unnecessary `else`
    |
236 |         return y
    -     else:
237 |   # comment
    -         c = 3
    -         return z
238 +     c = 3
239 +     return z
240 |
    |

RET505 [*] Unnecessary `else` after `return` statement
   --> RET505.py:245:2
    |
243 |     if True:
244 |      return True
245 |     else:
    |     ^^^^
246 |      return False
    |
help: Remove unnecessary `else`
    |
244 | 	 return True
    - 	else:
    - 	 return False
245 + 	return False
246 |
    |

RET505 Unnecessary `else` after `return` statement
   --> RET505.py:252:5
    |
250 |     if b'Untracked files' in result.stdout:
251 |         return True
252 |     else:
    |     ^^^^
253 | \
254 |         return False
    |
help: Remove unnecessary `else`
