mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-112345: typing.Protocol: Let failed subclasscheck show non-method members (#112344)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
d9fc15222e
commit
e9d1360c9a
3 changed files with 25 additions and 1 deletions
|
|
@ -1828,8 +1828,13 @@ class _ProtocolMeta(ABCMeta):
|
|||
not cls.__callable_proto_members_only__
|
||||
and cls.__dict__.get("__subclasshook__") is _proto_hook
|
||||
):
|
||||
non_method_attrs = sorted(
|
||||
attr for attr in cls.__protocol_attrs__
|
||||
if not callable(getattr(cls, attr, None))
|
||||
)
|
||||
raise TypeError(
|
||||
"Protocols with non-method members don't support issubclass()"
|
||||
"Protocols with non-method members don't support issubclass()."
|
||||
f" Non-method members: {str(non_method_attrs)[1:-1]}."
|
||||
)
|
||||
if not getattr(cls, '_is_runtime_protocol', False):
|
||||
raise TypeError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue