Comparison that is always True or always False
Reports an ==, !=, is, is not, in or not in comparison that is always True or always False, because the types of its operands do not overlap.
The inspection does not report a comparison with a type that can define its own __eq__ method, for example Decimal == 0. A class that is not final can get its own __eq__ method in a subclass. The inspection ignores the subclasses of str, bytes and the number types.
The inspection reports in and not in only for a builtin tuple, list, set, frozenset or dict. Another container can define its own __contains__ method.
Example:
As a fix, compare values of the same type, or correct the type annotation.
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
PyNonOverlappingComparison- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection ID: PyNonOverlappingComparisonInspection
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: | CLion 2026.3, IntelliJ IDEA 2026.3, PyCharm 2026.3, Qodana for JVM 2026.3, |