News for hackers. Stuff that matters.
Re:Interfaces and Protocols in Python by zeugmasyllepsis on Saturday March 20, 2021 @10:38AM (#26523516)
Right - so if you're introducing type annotations into an existing project and have a method expecting some interface, used by many call-sites spread across various parts of the project, then you can go around wrapping the original type at each call-site as you've indicated.

Or add a single type annotations to the method declaring that the parameter satisfies a protocol.

Re:Interfaces and Protocols in Python by neolog on Saturday March 20, 2021 @06:13PM (#26526429)

    implementer(IReceiver)(builtins.set)
only needs to be written once, not once at each call site. It's telling the global registry that builtins.set implements IReceiver.