Open perkinslr opened 2 weeks ago
From my perspective, this poses some challenges. 1) It is important for us to keep type_enforced pure python and without any deps. 2) The zope interface is fairly non pythonic. If we add support for this, are there other packages we would want to support?
How do you envision support for Zope would look?
Zope Interfaces are still often used in software using
twisted
and related technologies. It would be nice iftype_enforced
supported these interfaces in its type checking.The critical checker is provided by
zope.interface.verify.verifyObject(iface, candidate, tentative)
, wheretentative
indicates if objects that just happen to provide the interface are good enough, or if they must explicitly support it.Note this can sorta be done via GenericConstraints, but those run after the rest of the type checking, so you have to pick between a constraint for an interface, or a basic type. So you cannot do
def foo(bar: [int, IBar]):