Skip to content

Support typing.Protocol #135

Open
Open

Description

PEP-0544 introduce typing.Protocol which allows defining an interface that can be validated on runtime.
This is currently available via a non-official extension to the typing module called typing-extensions.

Although it seems similar to zope functionality, it is very different:

  1. It does not verify the arguments of the methods. Not that the implementation has the correct number of arguments and not the arguments' typing.
  2. Their implementation meant for static type checking.

Can zope utilize the already existing validation implementation to also validate Protocols on runtime.
This will allow a developer to write an interface once (via a Protocol) that could be checked statically using the existing Protocol implementation and also dynamically using zope's implementation.

See more information on this StackOverflow thread: https://stackoverflow.com/questions/43830996/verify-that-an-unknown-module-object-is-obliged-to-a-specific-interface-python/55131689

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions