use-eq-for-primitives¶
Enforces the use of == and != in comparisons to primitives rather than is and is not.
The == operator checks equality, while is checks identity.
Message¶
Don’t use is or is not to compare primitives, as they compare references. Use == or != instead.
References¶
Valid examples¶
a == 1
a == '1'
a != '1'
'3' == '1'
3 == '1'
3 > 2 > 1
Show more
3 > 2 > '1'
a is b > 1
a is b is c
1 > b is c
Invalid examples¶
a is 1
Suggested fix
a == 1
a is '1'
Suggested fix
a == '1'
a is f'1{b}'
Suggested fix
a == f'1{b}'
Show more
a is not f'1{d}'
Suggested fix
a != f'1{d}'
1 is a
Suggested fix
1 == a
'2' > '1' is a
Suggested fix
'2' > '1' == a
3 > a is 2
Suggested fix
3 > a == 2
1 is 2
Suggested fix
1 == 2