Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-112345: Let failed protocol subclasscheck show non-method members #112344

Merged
merged 11 commits into from
Nov 24, 2023
7 changes: 6 additions & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,8 +1828,13 @@ def __subclasscheck__(cls, other):
not cls.__callable_proto_members_only__
and cls.__dict__.get("__subclasshook__") is _proto_hook
):
non_method_attrs = {
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
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: {non_method_attrs}."
randolf-scholz marked this conversation as resolved.
Show resolved Hide resolved
)
if not getattr(cls, '_is_runtime_protocol', False):
raise TypeError(
Expand Down