Skip to content

Files

Latest commit

 

History

History
31 lines (21 loc) · 594 Bytes

unnecessary-pass.md

File metadata and controls

31 lines (21 loc) · 594 Bytes

Pattern: Unnecessary pass statement

Issue: -

Description

A pass statement is only necessary when it is the only statement in a block. If the block already contains other statements then the pass statement is unnecessary and can be removed.

Example of incorrect code:

try:
    A = 1
except ValueError:
    A = 2
    pass # [unnecessary-pass]

Example of correct code:

try:
    A = 1
except ValueError:
    pass

Further Reading