Ian Bicking: the old part of his blog

Reoptionalstatictyping comment 000

PyProtocols actually does include one paramerizable interface factory: sequenceOf(aProtocol) returns a protocol object representing a "sequence of aProtocol". It's left to the user to create other parameterized interfaces if they have the need. You could also subclass protocols.InterfaceClass and add a __getitem__ method to create parameterizable interfaces, although you might need a couple of other things. Hm, maybe something like:

class IFactory(ParamaterizedInterface):

    createsType = InterfaceParameter()

    def create() -> createsType:
        """Create an instance of the appropriate type"""

and then IFactory[IFoo] would represent something whose create method returns an IFoo. Adapting to an InterfaceParameter directly would always raise an error; the idea is that the __getitem__ would somehow clone the methods and change their type signatures in the non-parameterized version of the interface.

Comment on Re: Optional Static Typing
by Phillip J. Eby