]> granicus.if.org Git - python/commit
bpo-37058: PEP 544: Add Protocol to typing module (GH-13585)
authorIvan Levkivskyi <levkivskyi@gmail.com>
Tue, 28 May 2019 07:40:15 +0000 (08:40 +0100)
committerGitHub <noreply@github.com>
Tue, 28 May 2019 07:40:15 +0000 (08:40 +0100)
commit74d7f76e2c953fbfdb7ce01b7319d91d471cc5ef
tree6bba7b64dc4b4a88569809f0758113c87bb690b4
parent3880f263d2994fb1eba25835dddccb0cf696fdf0
bpo-37058: PEP 544: Add Protocol to typing module (GH-13585)

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.
Doc/library/typing.rst
Lib/test/test_typing.py
Lib/typing.py
Misc/NEWS.d/next/Library/2019-05-26-19-05-24.bpo-37058.jmRu_g.rst [new file with mode: 0644]