Skip to content

Remove unreachable code

Sourcery refactoring id: remove-unreachable-code

Description:

Removes code that will never be executed

Before:

for a in b:
    do_a()
    continue
    do_x()
    do_y()

After:

for a in b:
    do_a()
    continue

Explanation:

Statements after a continue, return or raise will never be executed. Leaving them in the code confuses the reader, who may believe that these statements have some effect. They should therefore be removed.

Back to top