When I'm using Pytest for Python formatting, it complains about doing something like:
>>> assert some_function_ret_val() == True
E712 comparison to True should be 'if cond is True:' or 'if cond:'
and wants:
assert some_function_ret_val() is True
I know there can only be one copy of True/False/None, but I thought all primitives are immutable types.
Under what circumstances would "==" and "is" comparison be different for primitive types??
Otherwise, why has "==" become the norm in comparison tasks?
I found this stackoverflow post that talks about comparison with non-primitive types, but I can't seem to find a reason for why "is" comparison might be dangerous with primitive types. Comparison with boolean numpy arrays VS PEP8 E712
If it's just convention, I would think that "is" is more legible than "==", but I feel like there could be some crazy edge cases where maybe there are more than one copy of a primitive type.