'"E721: do not compare types, use isinstance()" error

The python PEP 8 linter doesn't like this:

assert type(a) == type(b)

It tells me to use "isinstance()" instead. But to use isinstance I would have to do something like

assert isinstance(a, type(b)) and isinstance(b, type(a))

which seems much more unwiedly, and I don't really see the point.

Is the linter being wise in some way that I can't see? Or am I being wise in some way the linter can't see?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source