enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Fix RevPrefixMap to inherit directly from TraitType #1098

Closed mdickinson closed 2 years ago

mdickinson commented 2 years ago

This PR rewrites RevPrefixMap to inherit directly from TraitType rather than subclassing PrefixMap. This reduces the fragility of RevPrefixMap with respect to future upstream changes to PrefixMap.

To get to this code, I simply pasted in the Traits 6.2.0 version of PrefixMap under a new name OldPrefixMap to remove the dependence on upstream, and then refactored to collapse the RevPrefixMap -> OldPrefixMap -> TraitType inheritance tree to RevPrefixMap -> TraitType.

I've added some extra tests, to be sure that I didn't break existing behaviour while refactoring.

There are plenty of further cleanup and refactoring opportunities in RevPrefixMap (particularly in the __init__ and with the duplication between value_for and validate), but those are probably best left to the next minor feature release. I'm hoping that this PR can go into the 4.7.4 bugfix release.

Fixes #1094.

mdickinson commented 2 years ago

Actually, let me do at least a little bit of cleanup in the __init__ method.

mdickinson commented 2 years ago

Actually, let me do at least a little bit of cleanup in the __init__ method.

Done.

mdickinson commented 2 years ago

Sorry, @rahulporuri. In case it wasn't clear, I'm done tinkering with this PR. (There's lots more I'd love to do given time, but I don't have that time right now, and this seems like it should be enough for the bugfix.)