enthought / traits

Observable typed attributes for Python classes
Other
436 stars 85 forks source link

Adaptation manager has ill-defined `sort` usage. #172

Open mdickinson opened 10 years ago

mdickinson commented 10 years ago

In AdaptationManager._adapt there's a line:

                edges.sort(cmp=_by_weight_then_from_protocol_specificity)

But the _by_weight_then_from_protocol_specificity function doesn't give a transitive relation, so the results of the sort are undefined. It's not clear to me how important the sort order is here.

mdickinson commented 10 years ago

Maybe sort by weight and class depth (in the sense of the shortest path from the class to object in the 'is_a_direct_subclass' DAG)?

mdickinson commented 4 years ago

See #883 for one approach to solving this; I've closed that PR, but we may want to pick up the code from that PR again as a basis for a solution at some point in the future (though I think there are also other approaches).