Skip to content

Remove imports from traitsui.editors.__init__ #1759

@corranwebster

Description

@corranwebster

A long time ago, all editor factories were imported directly from traitsui.editors. Over a decade ago, the traitsui.editors.api module was added, but import from traitsui.editors was still kept for backwards compatibility.

However this causes problems with circular imports in a number of places (eg. see discussion here:

### Note: Declare the editor to be a function which returns the RGBColorEditor
# class from traits ui to avoid circular import issues. For backwards
# compatibility with previous Traits versions, the 'editors' folder in Traits
# project declares 'from api import *' in its __init__.py. The 'api' in turn
# can contain classes that have a RGBColor trait which lead to this file getting
# imported. This will lead to a circular import when declaring a RGBColor
# trait.
).

We should remove the imports from traitsui.editors.__init__ and fix situations where we are working around circular imports.

This would technically be a breaking change, but the impact is like very low at this point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: coreIssues related to the core functionality, ui composition and life cycle.difficulty: easyIssues which don't need much/any context about the package.type: cleanupIssues related to clean up _excluding_ refactoring

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions