How to pass a reference to a protocol class

Hi!

Creating new topic for PEP 544 as I couldn’t find one here already. Hope it is OK to also discuss on accepted PEPs.

I’m in a position, where I’d like to be able to pass a reference to a Protocol Class, however, I can’t find a way to describe that variable with the current type system, as Type[ProtocolClass] means a class implementing said protocol, where I want the protocol itself, while ProtocolClass means an instance of a class implementing the protocol.

So I haven’t figured out if the PEP specifies a type that describes the Protocol class itself, rather than just its compatible implementations.

I tried to file this as a mypy bug, but no response yet, and alas, figure it may even be overlooked by the PEP in question.

Any way, I’d very much appreciate a few more eyes and input on this matter.

Thank you,
Cheers

1 Like

Accepted PEPs are historical documents, so I have moved your post to “Users” to see if someone will be able to help.

2 Likes

You can also ask on the typing-sig mailing list for help.

1 Like

I got excellent help on the mypy issue on GitHub, and resolved to not use Protocol classes for the interface, but rather ABCs, given my runtime aspects of the use case.

2 Likes