1.1 --- a/deducer.py Thu Oct 06 19:29:53 2016 +0200
1.2 +++ b/deducer.py Fri Oct 07 13:51:28 2016 +0200
1.3 @@ -959,21 +959,32 @@
1.4 # For each class type suggested by the usage, examine the
1.5 # attribute provided for the attribute name.
1.6
1.7 - for class_type in self.get_class_types_for_usage(usage):
1.8 - ref = self.importer.get_class_attribute(class_type, attrname)
1.9 -
1.10 - # Test the attribute for being an unbound method provided by
1.11 - # the class or an ancestor.
1.12 -
1.13 - parent_class = ref and ref.parent()
1.14 -
1.15 - if ref and ref.has_kind("<function>") and (
1.16 - class_type == parent_class or class_type in self.descendants[parent_class]):
1.17 -
1.18 - # Record all class types providing the unbound method.
1.19 -
1.20 - init_item(self.invoked_attr_types, location, set)
1.21 - self.invoked_attr_types[location].add(class_type)
1.22 + providers = self.get_unbound_method_providers(self.get_class_types_for_usage(usage), attrname)
1.23 +
1.24 + # Record all class types providing the unbound method.
1.25 +
1.26 + init_item(self.invoked_attr_types, location, set)
1.27 + self.invoked_attr_types[location].update(providers)
1.28 +
1.29 + def get_unbound_method_providers(self, class_types, attrname):
1.30 +
1.31 + providers = set()
1.32 +
1.33 + for class_type in class_types:
1.34 + ref = self.importer.get_class_attribute(class_type, attrname)
1.35 +
1.36 + # Test the attribute for being an unbound method provided by
1.37 + # the class or an ancestor.
1.38 +
1.39 + parent_class = ref and ref.parent()
1.40 +
1.41 + if ref and ref.has_kind("<function>") and (
1.42 + class_type == parent_class or
1.43 + class_type in self.descendants[parent_class]):
1.44 +
1.45 + providers.add(class_type)
1.46 +
1.47 + return providers
1.48
1.49 # Simplification of types.
1.50