Expose type(Protocol)
via types
.
#1478
Labels
topic: feature
Discussions about new features for Python's type annotations
Library A might expose
SomeProtocol
, but internally realize classes that implementSomeProtocol
via some abstract base class.Since Protocols also provide the
@abstractmethod
checking thatabc.ABC
does, and might provide default implementations for mixin methods, it makes sense forMyProtocolABC
to subclassSomeProtocol
.If further class customization is required, a custom metaclass can be used. However, to avoid metaclass-conflicts,
MyMetaClass
must subclasstype(Protocol)
. Type-Checkers do not like this, since it's considered a dynamic type. On the other hand, one doesn't want to import the private membertyping._ProtocolMeta
.Therefore, it would be useful to expose
ProtocolType=type(Protocol)
in thetypes
module.The text was updated successfully, but these errors were encountered: