All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.py.rules.python.S3403.html Maven / Gradle / Ivy

There is a newer version: 4.23.0.17664
Show newest version

This rule raises an issue when an identity comparison operator is used to compare objects of different types.

Why is this an issue?

Operators is and is not check if their operands point to the same instance, thus they will always return respectively False and True when they are used to compare objects of different types.

Code examples

Noncompliant code example

a = 1
b = "1"
value = a is b  # Noncompliant. Always False
value = a is not b  # Noncompliant. Always True

Compliant solution

a = 1
b = 1
value = a is b
value = a is not b

Resources

Documentation





© 2015 - 2024 Weber Informatics LLC | Privacy Policy