---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
unreachable.py:3:5: PLW0101 Unreachable code in `after_return`
  |
1 | def after_return():
2 |     return "reachable"
3 |     return "unreachable"
  |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
4 | 
5 | async def also_works_on_async_functions():
  |

unreachable.py:7:5: PLW0101 Unreachable code in `also_works_on_async_functions`
  |
5 | async def also_works_on_async_functions():
6 |     return "reachable"
7 |     return "unreachable"
  |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
8 | 
9 | def if_always_true():
  |

unreachable.py:12:5: PLW0101 Unreachable code in `if_always_true`
   |
10 |     if True:
11 |         return "reachable"
12 |     return "unreachable"
   |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
13 | 
14 | def if_always_false():
   |

unreachable.py:16:9: PLW0101 Unreachable code in `if_always_false`
   |
14 | def if_always_false():
15 |     if False:
16 |         return "unreachable"
   |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
17 |     return "reachable"
   |

unreachable.py:21:9: PLW0101 Unreachable code in `if_elif_always_false`
   |
19 |   def if_elif_always_false():
20 |       if False:
21 |           return "unreachable"
   |  _________^
22 | |     elif False:
23 | |         return "also unreachable"
   | |_________________________________^ PLW0101
24 |       return "reachable"
   |

unreachable.py:28:9: PLW0101 Unreachable code in `if_elif_always_true`
   |
26 | def if_elif_always_true():
27 |     if False:
28 |         return "unreachable"
   |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
29 |     elif True:
30 |         return "reachable"
   |

unreachable.py:31:5: PLW0101 Unreachable code in `if_elif_always_true`
   |
29 |     elif True:
30 |         return "reachable"
31 |     return "also unreachable"
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0101
32 | 
33 | def ends_with_if():
   |

unreachable.py:35:9: PLW0101 Unreachable code in `ends_with_if`
   |
33 | def ends_with_if():
34 |     if False:
35 |         return "unreachable"
   |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
36 |     else:
37 |         return "reachable"
   |

unreachable.py:42:5: PLW0101 Unreachable code in `infinite_loop`
   |
40 |     while True:
41 |         continue
42 |     return "unreachable"
   |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
43 | 
44 | '''  TODO: we could determine these, but we don't yet.
   |

unreachable.py:75:5: PLW0101 Unreachable code in `match_wildcard`
   |
73 |         case _:
74 |             return "reachable"
75 |     return "unreachable"
   |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
76 | 
77 | def match_case_and_wildcard(status):
   |

unreachable.py:83:5: PLW0101 Unreachable code in `match_case_and_wildcard`
   |
81 |         case _:
82 |             return "reachable"
83 |     return "unreachable"
   |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
84 | 
85 | def raise_exception():
   |

unreachable.py:87:5: PLW0101 Unreachable code in `raise_exception`
   |
85 | def raise_exception():
86 |     raise Exception
87 |     return "unreachable"
   |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
88 | 
89 | def while_false():
   |

unreachable.py:91:9: PLW0101 Unreachable code in `while_false`
   |
89 | def while_false():
90 |     while False:
91 |         return "unreachable"
   |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
92 |     return "reachable"
   |

unreachable.py:96:9: PLW0101 Unreachable code in `while_false_else`
   |
94 | def while_false_else():
95 |     while False:
96 |         return "unreachable"
   |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
97 |     else:
98 |         return "reachable"
   |

unreachable.py:102:9: PLW0101 Unreachable code in `while_false_else_return`
    |
100 | def while_false_else_return():
101 |     while False:
102 |         return "unreachable"
    |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
103 |     else:
104 |         return "reachable"
    |

unreachable.py:105:5: PLW0101 Unreachable code in `while_false_else_return`
    |
103 |     else:
104 |         return "reachable"
105 |     return "also unreachable"
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0101
106 | 
107 | def while_true():
    |

unreachable.py:110:5: PLW0101 Unreachable code in `while_true`
    |
108 |     while True:
109 |         return "reachable"
110 |     return "unreachable"
    |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
111 | 
112 | def while_true_else():
    |

unreachable.py:116:9: PLW0101 Unreachable code in `while_true_else`
    |
114 |         return "reachable"
115 |     else:
116 |         return "unreachable"
    |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
117 | 
118 | def while_true_else_return():
    |

unreachable.py:122:9: PLW0101 Unreachable code in `while_true_else_return`
    |
120 |           return "reachable"
121 |       else:
122 |           return "unreachable"
    |  _________^
123 | |     return "also unreachable"
    | |_____________________________^ PLW0101
124 |   
125 |   def while_false_var_i():
    |

unreachable.py:128:9: PLW0101 Unreachable code in `while_false_var_i`
    |
126 |     i = 0
127 |     while False:
128 |         i += 1
    |         ^^^^^^ PLW0101
129 |     return i
    |

unreachable.py:135:5: PLW0101 Unreachable code in `while_true_var_i`
    |
133 |     while True:
134 |         i += 1
135 |     return i
    |     ^^^^^^^^ PLW0101
136 | 
137 | def while_infinite():
    |

unreachable.py:140:5: PLW0101 Unreachable code in `while_infinite`
    |
138 |     while True:
139 |         pass
140 |     return "unreachable"
    |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
141 | 
142 | def while_if_true():
    |

unreachable.py:146:5: PLW0101 Unreachable code in `while_if_true`
    |
144 |         if True:
145 |             return "reachable"
146 |     return "unreachable"
    |     ^^^^^^^^^^^^^^^^^^^^ PLW0101
147 | 
148 | def while_break():
    |

unreachable.py:152:9: PLW0101 Unreachable code in `while_break`
    |
150 |         print("reachable")
151 |         break
152 |         print("unreachable")
    |         ^^^^^^^^^^^^^^^^^^^^ PLW0101
153 |     return "reachable"
    |

unreachable.py:248:5: PLW0101 Unreachable code in `after_return`
    |
246 |   def after_return():
247 |       return "reachable"
248 |       print("unreachable")
    |  _____^
249 | |     print("unreachable")
250 | |     print("unreachable")
251 | |     print("unreachable")
252 | |     print("unreachable")
    | |________________________^ PLW0101
    |

unreachable.py:257:5: PLW0101 Unreachable code in `check_if_url_exists`
    |
255 |   def check_if_url_exists(url: str) -> bool:  # type: ignore[return]
256 |       return True  # uncomment to check URLs
257 |       response = requests.head(url, allow_redirects=True)
    |  _____^
258 | |     if response.status_code == 200:
259 | |         return True
260 | |     if response.status_code == 404:
261 | |         return False
262 | |     console.print(f"[red]Unexpected error received: {response.status_code}[/]")
263 | |     response.raise_for_status()
    | |_______________________________^ PLW0101
    |
