A
Alex Willmer
Hello,
I'm looking for a way to find the occurrences of x is y comparisons in
an existing code base. Except for a few special cases (e.g. x is [not]
None) they're a usually mistakes, the correct test being x == y.
However they happen to work most of the time on CPython (e.g. when y
is a small integer or string) so they slip into production code
unnoticed.
PyLint and PyFlakes don't check this AFAICT. Any suggestions for such
a tool, or a pointer how to add the check to an existing tool would be
most welcome.
Regards, Alex
I'm looking for a way to find the occurrences of x is y comparisons in
an existing code base. Except for a few special cases (e.g. x is [not]
None) they're a usually mistakes, the correct test being x == y.
However they happen to work most of the time on CPython (e.g. when y
is a small integer or string) so they slip into production code
unnoticed.
PyLint and PyFlakes don't check this AFAICT. Any suggestions for such
a tool, or a pointer how to add the check to an existing tool would be
most welcome.
Regards, Alex