---
source: crates/ruff_linter/src/rules/flake8_return/mod.rs
---
RET507.py:8:9: RET507 [*] Unnecessary `elif` after `continue` statement
   |
 6 |         if i < y:  # [no-else-continue]
 7 |             continue
 8 |         elif i < w:
   |         ^^^^ RET507
 9 |             continue
10 |         else:
   |
   = help: Remove unnecessary `elif`

ℹ Safe fix
5 5 |     for i in x:
6 6 |         if i < y:  # [no-else-continue]
7 7 |             continue
8   |-        elif i < w:
  8 |+        if i < w:
9 9 |             continue
10 10 |         else:
11 11 |             a = z

RET507.py:22:9: RET507 [*] Unnecessary `elif` after `continue` statement
   |
20 |                 b = 2
21 |             continue
22 |         elif z:
   |         ^^^^ RET507
23 |             c = 2
24 |         else:
   |
   = help: Remove unnecessary `elif`

ℹ Safe fix
19 19 |             else:
20 20 |                 b = 2
21 21 |             continue
22    |-        elif z:
   22 |+        if z:
23 23 |             c = 2
24 24 |         else:
25 25 |             c = 3

RET507.py:36:9: RET507 [*] Unnecessary `else` after `continue` statement
   |
34 |         if i < y:  # [no-else-continue]
35 |             continue
36 |         else:
   |         ^^^^ RET507
37 |             a = z
   |
   = help: Remove unnecessary `else`

ℹ Safe fix
33 33 |     for i in x:
34 34 |         if i < y:  # [no-else-continue]
35 35 |             continue
36    |-        else:
37    |-            a = z
   36 |+        a = z
38 37 | 
39 38 | 
40 39 | def foo3(x, y, z):

RET507.py:47:13: RET507 [*] Unnecessary `else` after `continue` statement
   |
45 |                 b = 2
46 |                 continue
47 |             else:
   |             ^^^^ RET507
48 |                 c = 3
49 |                 continue
   |
   = help: Remove unnecessary `else`

ℹ Safe fix
44 44 |             if z:  # [no-else-continue]
45 45 |                 b = 2
46 46 |                 continue
47    |-            else:
48    |-                c = 3
49    |-                continue
   47 |+            c = 3
   48 |+            continue
50 49 |         else:
51 50 |             d = 4
52 51 |             continue

RET507.py:63:9: RET507 [*] Unnecessary `else` after `continue` statement
   |
61 |                 b = 2
62 |             continue
63 |         else:
   |         ^^^^ RET507
64 |             c = 3
65 |         continue
   |
   = help: Remove unnecessary `else`

ℹ Safe fix
60 60 |             else:
61 61 |                 b = 2
62 62 |             continue
63    |-        else:
64    |-            c = 3
   63 |+        c = 3
65 64 |         continue
66 65 | 
67 66 | 

RET507.py:74:13: RET507 [*] Unnecessary `else` after `continue` statement
   |
72 |                 a = 4
73 |                 continue
74 |             else:
   |             ^^^^ RET507
75 |                 b = 2
76 |         else:
   |
   = help: Remove unnecessary `else`

ℹ Safe fix
71 71 |             if y:  # [no-else-continue]
72 72 |                 a = 4
73 73 |                 continue
74    |-            else:
75    |-                b = 2
   74 |+            b = 2
76 75 |         else:
77 76 |             c = 3
78 77 |         continue

RET507.py:85:9: RET507 [*] Unnecessary `else` after `continue` statement
   |
83 |         if x:  # [no-else-continue]
84 |             continue
85 |         else:
   |         ^^^^ RET507
86 |             try:
87 |                 return
   |
   = help: Remove unnecessary `else`

ℹ Safe fix
82 82 |     for i in range(10):
83 83 |         if x:  # [no-else-continue]
84 84 |             continue
85    |-        else:
86    |-            try:
87    |-                return
88    |-            except ValueError:
89    |-                continue
   85 |+        try:
   86 |+            return
   87 |+        except ValueError:
   88 |+            continue
90 89 | 
91 90 | 
92 91 | def bar1(x, y, z):


