Skip to content
Advertisement

How can you test that a python typing Protocol is a subclass of another Protocol?

The obvious solution to the problem is to use issubclass, but this raises TypeError (using Python 3.6.7), e.g.

JavaScript

Advertisement

Answer

For more on the topic of python Protocols, see

In Python 3.6.7, one way to solve this is to use the @runtime_checkable decorator:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement