@@ -73,18 +73,19 @@ collapsible_else_if.py:55:5: PLR5501 [*] Use `elif` instead of `else` then `if`,
737352 52 | def not_ok1_with_comments ():
747453 53 | if 1 :
757554 54 | pass
76- 55 | + elif 2 :
77- 56 | + pass
78- 55 57 | else :
76+ 55 | + # inner comment
77+ 56 | + elif 2 :
78+ 57 | + pass
79+ 55 58 | else :
798056 | - # inner comment
808157 | - if 2 :
818258 | - pass
828359 | - else :
838460 | - pass # final pass comment
84- 58 | + pass # final pass comment
85- 61 59 |
86- 62 60 |
87- 63 61 | # Regression test for https :// github.com/apache/airflow/blob/f1e1cdcc3b2826e68ba133f350300b5065bbca33/airflow/models/dag.py#L1737
85+ 59 | + pass # final pass comment
86+ 61 60 |
87+ 62 61 |
88+ 63 62 | # Regression test for https :// github.com/apache/airflow/blob/f1e1cdcc3b2826e68ba133f350300b5065bbca33/airflow/models/dag.py#L1737
8889
8990collapsible_else_if .py :69 :5 : PLR5501 [* ] Use ` elif` instead of ` else` then ` if` , to reduce indentation
9091 |
@@ -181,15 +182,150 @@ collapsible_else_if.py:96:5: PLR5501 [*] Use `elif` instead of `else` then `if`,
181182 = help : Convert to ` elif`
182183
183184ℹ Safe fix
184- 93 93 | def not_ok5 ():
185- 94 94 | if 1 :
186- 95 95 | pass
187- 96 | - else :
188- 97 | - if 2 :
189- 98 | - pass
190- 99 | - else : pass
191- 96 | + elif 2 :
192- 97 | + pass
193- 98 | + else : pass
185+ 93 93 | def not_ok5 ():
186+ 94 94 | if 1 :
187+ 95 95 | pass
188+ 96 | - else :
189+ 97 | - if 2 :
190+ 98 | - pass
191+ 99 | - else : pass
192+ 96 | + elif 2 :
193+ 97 | + pass
194+ 98 | + else : pass
195+ 100 99 |
196+ 101 100 |
197+ 102 101 | def not_ok1_with_multiline_comments ():
194198
199+ collapsible_else_if .py :105 :5 : PLR5501 [* ] Use ` elif` instead of ` else` then ` if` , to reduce indentation
200+ |
201+ 103 | if 1 :
202+ 104 | pass
203+ 105 | else :
204+ | _____ ^
205+ 106 | | # inner comment which happens
206+ 107 | | # to be longer than one line
207+ 108 | | if 2 :
208+ | | ________ ^ PLR5501
209+ 109 | pass
210+ 110 | else :
211+ |
212+ = help : Convert to ` elif`
195213
214+ ℹ Safe fix
215+ 102 102 | def not_ok1_with_multiline_comments ():
216+ 103 103 | if 1 :
217+ 104 104 | pass
218+ 105 | + # inner comment which happens
219+ 106 | + # to be longer than one line
220+ 107 | + elif 2 :
221+ 108 | + pass
222+ 105 109 | else :
223+ 106 | - # inner comment which happens
224+ 107 | - # to be longer than one line
225+ 108 | - if 2 :
226+ 109 | - pass
227+ 110 | - else :
228+ 111 | - pass # final pass comment
229+ 110 | + pass # final pass comment
230+ 112 111 |
231+ 113 112 |
232+ 114 113 | def not_ok1_with_deep_indented_comments ():
233+
234+ collapsible_else_if .py :117 :5 : PLR5501 [* ] Use ` elif` instead of ` else` then ` if` , to reduce indentation
235+ |
236+ 115 | if 1 :
237+ 116 | pass
238+ 117 | else :
239+ | _____ ^
240+ 118 | | # inner comment which happens to be overly indented
241+ 119 | | if 2 :
242+ | | ________ ^ PLR5501
243+ 120 | pass
244+ 121 | else :
245+ |
246+ = help : Convert to ` elif`
247+
248+ ℹ Safe fix
249+ 114 114 | def not_ok1_with_deep_indented_comments ():
250+ 115 115 | if 1 :
251+ 116 116 | pass
252+ 117 | + # inner comment which happens to be overly indented
253+ 118 | + elif 2 :
254+ 119 | + pass
255+ 117 120 | else :
256+ 118 | - # inner comment which happens to be overly indented
257+ 119 | - if 2 :
258+ 120 | - pass
259+ 121 | - else :
260+ 122 | - pass # final pass comment
261+ 121 | + pass # final pass comment
262+ 123 122 |
263+ 124 123 |
264+ 125 124 | def not_ok1_with_shallow_indented_comments ():
265+
266+ collapsible_else_if .py :128 :5 : PLR5501 [* ] Use ` elif` instead of ` else` then ` if` , to reduce indentation
267+ |
268+ 126 | if 1 :
269+ 127 | pass
270+ 128 | else :
271+ | _____ ^
272+ 129 | | # inner comment which happens to be under indented
273+ 130 | | if 2 :
274+ | | ________ ^ PLR5501
275+ 131 | pass
276+ 132 | else :
277+ |
278+ = help : Convert to ` elif`
279+
280+ ℹ Safe fix
281+ 125 125 | def not_ok1_with_shallow_indented_comments ():
282+ 126 126 | if 1 :
283+ 127 127 | pass
284+ 128 | - else :
285+ 129 128 | # inner comment which happens to be under indented
286+ 130 | - if 2 :
287+ 131 | - pass
288+ 132 | - else :
289+ 133 | - pass # final pass comment
290+ 129 | + elif 2 :
291+ 130 | + pass
292+ 131 | + else :
293+ 132 | + pass # final pass comment
294+ 134 133 |
295+ 135 134 |
296+ 136 135 | def not_ok1_with_mixed_indented_comments ():
297+
298+ collapsible_else_if .py :139 :5 : PLR5501 [* ] Use ` elif` instead of ` else` then ` if` , to reduce indentation
299+ |
300+ 137 | if 1 :
301+ 138 | pass
302+ 139 | else :
303+ | _____ ^
304+ 140 | | # inner comment which has mixed
305+ 141 | | # indentation levels
306+ 142 | | # which is pretty weird
307+ 143 | | if 2 :
308+ | | ________ ^ PLR5501
309+ 144 | pass
310+ 145 | else :
311+ |
312+ = help : Convert to ` elif`
313+
314+ ℹ Safe fix
315+ 136 136 | def not_ok1_with_mixed_indented_comments ():
316+ 137 137 | if 1 :
317+ 138 138 | pass
318+ 139 | + # inner comment which has mixed
319+ 140 | + # indentation levels
320+ 141 | + # which is pretty weird
321+ 142 | + elif 2 :
322+ 143 | + pass
323+ 139 144 | else :
324+ 140 | - # inner comment which has mixed
325+ 141 | - # indentation levels
326+ 142 | - # which is pretty weird
327+ 143 | - if 2 :
328+ 144 | - pass
329+ 145 | - else :
330+ 146 | - pass # final pass comment
331+ 145 | + pass # final pass comment
0 commit comments