# HG changeset patch # User Paul Boddie # Date 1475841088 -7200 # Node ID caa13d1fb177ac1b61c5ae39995180732b88cc28 # Parent 6cc807f909843c5e7f18cb821439081542ce5411 Created a separate method for identifying unbound method providers. diff -r 6cc807f90984 -r caa13d1fb177 deducer.py --- a/deducer.py Thu Oct 06 19:29:53 2016 +0200 +++ b/deducer.py Fri Oct 07 13:51:28 2016 +0200 @@ -959,21 +959,32 @@ # For each class type suggested by the usage, examine the # attribute provided for the attribute name. - for class_type in self.get_class_types_for_usage(usage): - ref = self.importer.get_class_attribute(class_type, attrname) - - # Test the attribute for being an unbound method provided by - # the class or an ancestor. - - parent_class = ref and ref.parent() - - if ref and ref.has_kind("") and ( - class_type == parent_class or class_type in self.descendants[parent_class]): - - # Record all class types providing the unbound method. - - init_item(self.invoked_attr_types, location, set) - self.invoked_attr_types[location].add(class_type) + providers = self.get_unbound_method_providers(self.get_class_types_for_usage(usage), attrname) + + # Record all class types providing the unbound method. + + init_item(self.invoked_attr_types, location, set) + self.invoked_attr_types[location].update(providers) + + def get_unbound_method_providers(self, class_types, attrname): + + providers = set() + + for class_type in class_types: + ref = self.importer.get_class_attribute(class_type, attrname) + + # Test the attribute for being an unbound method provided by + # the class or an ancestor. + + parent_class = ref and ref.parent() + + if ref and ref.has_kind("") and ( + class_type == parent_class or + class_type in self.descendants[parent_class]): + + providers.add(class_type) + + return providers # Simplification of types.