Skip to content

Commit d16284d

Browse files
committed
Decide a member's ownership by the class dictionary
attr_is_not_inherited() compared the attribute's value with each base's. That took an inherited classmethod for the class's own, since a bound method compares unequal across classes, and dropped an own attribute whose value matched a base's default None: 394 of CPython's in all, ast.FunctionDef.returns among them. On the RustPython side it called AttributeError.name, a class attribute set to None, inherited. Ownership now means the class dictionary holds the name. An inherited member is reported only when what it resolves to differs from CPython's own, so dict_items.__doc__, a slot CPython fills with None that RustPython resolves to None without one, stays quiet. "(inherited)" lines drop from 196 to 54, and ast.alias.end_lineno is among the real gaps that appear. Assisted-by: Claude Code:claude-fable-5-1
1 parent ee0eb10 commit d16284d

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎scripts/whats_left.py‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ def attr_is_not_inherited(type_, attr):
111111
"""
112112
returns True if type_'s attr is not inherited from any of its base classes
113113
"""
114-
bases = type_.__mro__[1:]
115-
return getattr(type_, attr) not in (getattr(base, attr, None) for base in bases)
114+
return attr in type_.__dict__
116115

117116

118117
def extra_info(obj):
@@ -398,13 +397,15 @@ def compare():
398397
import warnings
399398
from contextlib import redirect_stdout
400399

401-
def method_incompatibility_reason(typ, method_name):
400+
def method_incompatibility_reason(typ, method_name, real_method_value):
402401
has_method = hasattr(typ, method_name)
403402
if not has_method:
404403
return ""
405404

406405
is_inherited = not attr_is_not_inherited(typ, method_name)
407-
if is_inherited:
406+
# Inheriting something that reads the same as CPython's own member
407+
# leaves nothing to implement.
408+
if is_inherited and extra_info(getattr(typ, method_name)) != real_method_value:
408409
return "(inherited)"
409410

410411
return None
@@ -415,7 +416,7 @@ def method_incompatibility_reason(typ, method_name):
415416
for name, (typ, real_value, methods) in expected_methods.items():
416417
missing_methods = {}
417418
for method, real_method_value in methods:
418-
reason = method_incompatibility_reason(typ, method)
419+
reason = method_incompatibility_reason(typ, method, real_method_value)
419420
if reason is not None:
420421
missing_methods[method] = reason
421422
continue
@@ -483,10 +484,12 @@ def method_incompatibility_reason(typ, method_name):
483484
skipped.add(item)
484485
elif not hasattr(cls, attr):
485486
continue
486-
elif not attr_is_not_inherited(cls, attr):
487-
inherited.add(item)
488-
else:
487+
elif attr_is_not_inherited(cls, attr):
489488
rustpymod[item] = extra_info(getattr(cls, attr))
489+
elif extra_info(getattr(cls, attr)) == cpymod[item]:
490+
rustpymod[item] = cpymod[item]
491+
else:
492+
inherited.add(item)
490493
implemented_items = sorted(set(cpymod) & set(rustpymod))
491494
mod_missing_items = set(cpymod) - set(rustpymod) - skipped
492495
mod_missing_items = sorted(

0 commit comments

Comments
 (0)