From 7e2f5daff4891c63dc8131dc7b03bc4208bd1919 Mon Sep 17 00:00:00 2001 From: Jerome Berthier Date: Wed, 11 Sep 2019 17:06:36 +0200 Subject: [PATCH] [tools.backend] fix iter_caps not returning only Capabilities When working with multiple AbstractModule inheritance you may have Class1 and Class2 instanciated: Class1(Module, CapBank) Class2(AbstractModule, CapBank) (Abstract of Class1) Instanciating a class Class2 object, its MRO contains both Class1 and CapBank. So when looking for Class2 capabilities, the patched method as returning Class1 because actually Class1 is a subclass of Capability as it inherit from Class1. --- weboob/tools/backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weboob/tools/backend.py b/weboob/tools/backend.py index 8c50463ad6..3e421f5425 100644 --- a/weboob/tools/backend.py +++ b/weboob/tools/backend.py @@ -398,7 +398,7 @@ def iter_caps(klass): :rtype: iter[:class:`weboob.capabilities.base.Capability`] """ for base in klass.mro(): - if issubclass(base, Capability) and base != Capability and base != klass: + if issubclass(base, Capability) and base != Capability and base != klass and not issubclass(base, Module): yield base def has_caps(self, *caps): -- GitLab