Remove use of type_manager in apptools.naming, remove type_manager, and remove naming.adapter#219
Conversation
…due to naming.ui but that is a separate issue
kitchoi
left a comment
There was a problem hiding this comment.
I'm afraid I am not comfortable with the changes as the adapters logic are not covered in tests.
|
|
||
| # The context that the object is in. | ||
| context = Instance(Context) | ||
| pass |
There was a problem hiding this comment.
Where did context = Instance(Context) go?
Most of the subclasses of ContextAdapter are untested. I think this may be breaking InstanceContextAdapter, TraitDictContextAdapter, TraitListContextAdapter, which all reference a context attribute defined on this class, and I don't see context being defined on the Context class.
If we are keeping them, we should be adding tests to ensure this switch to adaptation works.
There was a problem hiding this comment.
Another possibility is that it has never worked on master, then we can just kill them?
|
For future reference, these are the observations made that result in the type manager being removed: The initial observation is that
However, the code path of Details of the static code analysisThe adaptation is called here: apptools/apptools/naming/context.py Line 755 in 8af7199 Which is called here: apptools/apptools/naming/context.py Line 706 in 8af7199 Which is, conditionally, called by Context.bind, rebind, unbind, lookup, lookup_binding, list_bindings and list_names.
In the For For When the argument is an empty string, the apptools/apptools/naming/context.py Lines 516 to 534 in 8af7199 So the code path never requires type managers. Further confirmation with manual testing(1) apptools/apptools/naming/ui/explorer.py Lines 26 to 35 in 8af7199 If the adapters are required, the type manager needs to be defined on the context, like in the example: apptools/examples/naming/explorer.py Lines 94 to 95 in 8af7199 (2) Even if we do define the adapters, they don't make a difference. If we modify the example file to use where And if I then applied the fix in enthought/pyface#810 so that it can be launched with wxPython4, we can see something like this (after manually expanding the tree nodes): If we then remove all the adapters in the example, the view looks exactly the same. |
kitchoi
left a comment
There was a problem hiding this comment.
LGTM.
We will need a news fragment for this change.
Yes, I launched |

fixes #136
part of #146
In this PR,
apptools.namingis converted to usetraits.adaptation, and theapptools.type_managersubpackage is removed. I did these in the same PR, but if a reviewer would prefer I can undo the last commit and defer the removal oftype_managerto another PR.It is important to note that the code relating to
type_managerinapptools.namingwas largely untested, and from what I can tell, unused. There is one example using it, but it seems to be broken for other reasons(? I need to investigate).I also looked for other non-apptools uses of
type_managerand could not find any. Also, as the issue suggests I looked into Mayavi to see if it used the type manager's objects directly via the naming module, and it does not appear to do so.Checklist