From 88c3852b734c33fcd85f134da11432826411c762 Mon Sep 17 00:00:00 2001 From: "Y. Sapir" Date: Sun, 5 May 2019 00:02:10 +0300 Subject: [PATCH 1/2] Don't check for methods on iter - it's a builtin function --- tests/not_impl_gen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/not_impl_gen.py b/tests/not_impl_gen.py index 2e20f5609..e70cfc51b 100644 --- a/tests/not_impl_gen.py +++ b/tests/not_impl_gen.py @@ -7,14 +7,13 @@ objects = [ float, frozenset, int, - iter, list, memoryview, range, set, str, tuple, - object + object, ] header = open("generator/not_impl_header.txt") From c38a3711d0151560b0ac73c01a5e9f4664c6ec01 Mon Sep 17 00:00:00 2001 From: "Y. Sapir" Date: Sun, 5 May 2019 00:05:13 +0300 Subject: [PATCH 2/2] Include reimplemented methods in whats_left.sh, and skip inherited methods --- tests/not_impl_gen.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/not_impl_gen.py b/tests/not_impl_gen.py index e70cfc51b..2f1df44a2 100644 --- a/tests/not_impl_gen.py +++ b/tests/not_impl_gen.py @@ -16,6 +16,18 @@ objects = [ object, ] + +def attr_is_not_inherited(type_, attr): + """ + returns True if type_'s attr is not inherited from any of its base classes + """ + + bases = obj.__mro__[1:] + + return getattr(obj, attr) not in ( + getattr(base, attr, None) for base in bases) + + header = open("generator/not_impl_header.txt") footer = open("generator/not_impl_footer.txt") output = open("snippets/whats_left_to_implement.py", "w") @@ -25,7 +37,11 @@ output.write("expected_methods = {\n") for obj in objects: output.write(f" '{obj.__name__}': ({obj.__name__}, [\n") - output.write("\n".join(f" '{attr}'," for attr in dir(obj))) + output.write("\n".join( + f" {attr!r}," + for attr in dir(obj) + if attr_is_not_inherited(obj, attr) + )) output.write("\n ])," + ("\n" if objects[-1] == obj else "\n\n")) output.write("}\n\n")