You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously subclassing typing.Iterable with typing.Protocol raised an error because typing.Iterable was not an actual protocol. This specific problem was fixed but there are other protocols which are not actual protocols, such as typing.AbstractSet.
My specific use-case is creating particularly spurred by the following line:
For example, if I wanted to extend collections.abc.Set to include the missing methods mentioned, I would approach it something like this:
# protocols.pyimporttyping# Created for consistency and `isinstance` usage.# Causes the mentioned error.classAbstractSet(typing.AbstractSet, typing.Protocol):
...
# collections_abc.pyimportprotocolsimportcollections.abc# Created to provide default implementations.classAbstractSet(collections.abc.Set, protocols.AbstractSet):
...
It seems to me that the current fix for users is to simply not subclass the protocols and write out the entire protocol themselves.
The text was updated successfully, but these errors were encountered:
Related: #561
Previously subclassing
typing.Iterable
withtyping.Protocol
raised an error becausetyping.Iterable
was not an actual protocol. This specific problem was fixed but there are other protocols which are not actual protocols, such astyping.AbstractSet
.My specific use-case is creating particularly spurred by the following line:
https://github.com/python/cpython/blob/144aaa74bbd77aee822ee92344744dbb05aa2f30/Lib/_collections_abc.py#L9
For example, if I wanted to extend
collections.abc.Set
to include the missing methods mentioned, I would approach it something like this:It seems to me that the current fix for users is to simply not subclass the protocols and write out the entire protocol themselves.
The text was updated successfully, but these errors were encountered: