Playground link
data1 = bytearray(4)
data2 = bytes(4)
if data1 == data2:
print("Four zeros are four zeros!")
Results in the warning Condition will always evaluate to False since the types "bytearray" and "bytes" have no overlap.
But this is incorrect, comparing bytearray and bytes with == returns True if they have the same content.
A related issue occurs with literals:
data = bytearray(4)
value = b"\0\0\0\0"
if data == value:
print("Four zeros are four zeros!")
Results in the warning Condition will always evaluate to False since the types "bytearray" and "Literal[b"\x00\x00\x00\x00"]" have no overlap.
Playground link
Results in the warning
Condition will always evaluate to False since the types "bytearray" and "bytes" have no overlap.But this is incorrect, comparing
bytearrayandbyteswith==returnsTrueif they have the same content.A related issue occurs with literals:
Results in the warning
Condition will always evaluate to False since the types "bytearray" and "Literal[b"\x00\x00\x00\x00"]" have no overlap.