Back to Intellij Community

PyComparisonWithNoneInspection

python/python-psi-impl/resources/inspectionDescriptions/PyComparisonWithNoneInspection.html

2025.3-rc-2301 B
Original Source

Reports comparisons with None. That type of comparisons should always be done with is or is not, never the equality operators.

Example:

a = 2

if a == None:
    print("Success")

Once the quick-fix is applied, the code changes to:

a = 2

if a is None:
    print("Success")