The following code causes PyCharm to detect the last line as 'unreachable code', despite it being completely reachable.
import random
def test_func():
while True:
print("start")
try:
if random.random() > 0.5:
break
finally:
print("Finally")
print("Done")
if __name__ == '__main__':
test_func()
When the try/finally block is not included, the error does not occur.
Here's a relevant screenshot:
The problem was already reported here and here and it should be fixed in PyCharm 2016.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With