enthought / enthought/traits

`traits.adapts` confused when run repeatedly in an interactive session.

Open
#46 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Using `traits.adapts` adds an adapter class to the adapter registry. If the same class is redefined, then traits can't choose between them. For example, try running the following example repeatedly in an ipython session (using `%run`): [Adapted_tree_editor_demo.py](https://github.com/enthought/traitsui/blob/master/examples/demo/Advanced/Adapted_tree_editor_demo.py)

The first time should run fine (this adds the class to the registry). The second time should fail (this adds the same class to the registry, and then it can't decide between the repeated entries).

One solution maybe to check the name and `__module__` of the class added to the registry. If those match something in the registry, then _replace_ the existing entry (since you might update the class before the second run).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.