address feedback

This commit is contained in:
Dinesh Yeduguru 2024-12-05 18:02:53 -08:00
parent 208fd33048
commit 04e6998d6f
6 changed files with 105 additions and 64 deletions

View file

@ -345,18 +345,15 @@ def check_protocol_compliance(obj: Any, protocol: Any) -> None:
)
missing_methods.append((name, "signature_mismatch"))
else:
# Check if the method is actually implemented in the class
method_owner = next(
(cls for cls in mro if name in cls.__dict__), None
)
proto_method = getattr(protocol, name)
if method_owner is None:
if (
method_owner is None
or method_owner.__name__ == protocol.__name__
):
print(mro)
missing_methods.append((name, "not_actually_implemented"))
elif method_owner.__name__ == protocol.__name__:
# Check if it's just a stub (...) or has real implementation
proto_source = inspect.getsource(proto_method)
if "..." in proto_source:
missing_methods.append((name, "not_actually_implemented"))
if missing_methods:
raise ValueError(