I’d like to define a union type of Protocols where the members of this union are to be determined in the future.
Here’s an example
@runtime_checkable class Parser(Protocol): ... ParserProtocols = Parser | Protocol def parse(parser: ParserProtocols): if isinstance(parser, Parser) ... else: raise NotImplementedError(...)
I expect to define other parser protocols in the future, but I want consumers of this type to be aware that a future parser implementing a different protocol are not interoperable (e.g., method of same name have different signature).
Parser | Protocol a good union type to signify this? Is there a better way?