• Ivan Levkivskyi's avatar
    bpo-37058: PEP 544: Add Protocol to typing module (GH-13585) · 74d7f76e
    Ivan Levkivskyi authored
    I tried to get rid of the `_ProtocolMeta`, but unfortunately it didn'y work. My idea to return a generic alias from `@runtime_checkable` made runtime protocols unpickleable. I am not sure what is worse (a custom metaclass or having some classes unpickleable), so I decided to stick with the status quo (since there were no complains so far). So essentially this is a copy of the implementation in `typing_extensions` with two modifications:
    * Rename `@runtime` to `@runtime_checkable` (plus corresponding updates).
    * Allow protocols that extend `collections.abc.Iterable` etc.
    74d7f76e
test_typing.py 111 KB