# HG changeset patch # User Paul Boddie # Date 1488667699 -3600 # Node ID 9168bc57af3d1aa2ca0b9fef6b59caacb4f5ccaa # Parent 25ac2cdf05a980334b03f35036f885d26f3ad45d Added a root class type variable and tidied up slightly. diff -r 25ac2cdf05a9 -r 9168bc57af3d deducer.py --- a/deducer.py Sat Mar 04 00:20:25 2017 +0100 +++ b/deducer.py Sat Mar 04 23:48:19 2017 +0100 @@ -35,6 +35,8 @@ "Deduce types in a program." + root_class_type = "__builtins__.object" + def __init__(self, importer, output): """ @@ -612,6 +614,7 @@ all_accessed_attrs.add(attr) all_providers.add(object_type) + self.reference_all_attrs[location] = all_accessed_attrs all_general_providers = self.get_most_general_types(all_providers) # Determine which attributes would be provided by the @@ -627,8 +630,6 @@ else: guard_attrs = None - self.reference_all_attrs[location] = all_accessed_attrs - # Constrained accesses guarantee the nature of the accessor. # However, there may still be many types involved. @@ -664,7 +665,7 @@ elif len(all_providers) == 1: provider = first(all_providers) - if provider != '__builtins__.object': + if provider != self.root_class_type: all_accessor_kinds = set(get_kinds(all_accessor_types)) if len(all_accessor_kinds) == 1: test_type = ("test", "specific", test_label_for_kind(first(all_accessor_kinds))) @@ -675,7 +676,7 @@ elif len(all_general_providers) == 1: provider = first(all_general_providers) - if provider != '__builtins__.object': + if provider != self.root_class_type: all_accessor_kinds = set(get_kinds(all_accessor_general_types)) if len(all_accessor_kinds) == 1: test_type = ("test", "common", test_label_for_kind(first(all_accessor_kinds))) @@ -1096,7 +1097,7 @@ # attributes. if len(module_types) == len(self.importer.modules): - return ["__builtins__.object"] + return [self.root_class_type] else: return module_types