Skip to content

Remove redundant pass

Sourcery refactoring id: remove-redundant-pass

Description:

Removes unnecessary pass statements

Before:

if a:
    x()
else:
    pass
do_something()
pass

After:

if a:
    x()
do_something()

Explanation:

A pass statement is unnecessary if a block has other statements in it, and an else which only contains pass can be safely removed. Making these changes shortens the code, and the reader doesn't have to consider and deal with the unnecessary pass statements.

Back to top