Skip to content

Files

Latest commit

 

History

History
24 lines (14 loc) · 531 Bytes

unidiomatic-typecheck.md

File metadata and controls

24 lines (14 loc) · 531 Bytes

Pattern: Unidiomatic type check

Issue: -

Description

This rule enforces PEP 8 recommendation to always use isinstance() instead of comparing types directly. Even though latter code is correct, it's less readable and is not considered 'pythonic'.

Example of incorrect code:

if type(obj) is type(1):

Example of correct code:

if isinstance(obj, int):

Further Reading