rspec/rules/S3403/python/rule.adoc

11 lines
544 B
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
Operators https://docs.python.org/3/reference/expressions.html#is-not[``++is++``] and https://docs.python.org/3/reference/expressions.html#is-not[``++is not++``] check if their operands point to the same instance, thus they will always return respectively True and False when they are used to compare objects of different type. Such comparisons can only be bugs.
2020-06-30 12:48:39 +02:00
== Noncompliant Code Example
----
myint = 1
mystring = "1"
value = myint is mystring # Noncompliant. Always False
value = myint is not mystring # Noncompliant. Always True
----