From 377cb480213ebec122bd918c751d68b5cfbdc0c4 Mon Sep 17 00:00:00 2001 From: Sai Rahul Poruri Date: Wed, 3 Feb 2021 11:38:54 +0530 Subject: [PATCH] CLN : Use api modules from ETS packages instead of importing from their internals import from traits.api, traitsui.api and pyface.api where possible --- enable/colors.py | 2 +- enable/savage/trait_defs/ui/svg_button_editor.py | 3 +-- enable/savage/trait_defs/ui/svg_editor.py | 3 +-- enable/savage/trait_defs/ui/toolkit.py | 2 +- enable/tests/primitives/test_image.py | 2 +- enable/tests/qt4/test_scrollbar.py | 2 +- enable/tests/test_component_editor.py | 6 ++---- enable/tests/tools/pyface/test_commands.py | 2 +- enable/tests/tools/pyface/test_move_command_tool.py | 2 +- enable/tests/tools/pyface/test_resize_command_tool.py | 2 +- enable/tests/tools/pyface/test_undo_tool.py | 2 +- enable/tests/tools/test_button_tool.py | 2 +- enable/toolkit.py | 2 +- enable/trait_defs/ui/wx/rgba_color_editor.py | 3 +-- 14 files changed, 15 insertions(+), 20 deletions(-) diff --git a/enable/colors.py b/enable/colors.py index efade5f55..aa124896c 100644 --- a/enable/colors.py +++ b/enable/colors.py @@ -167,7 +167,7 @@ if not ETSConfig.toolkit: # Force Traits to decide on its toolkit if it hasn't already - from traitsui.toolkit import toolkit as traits_toolkit + from traitsui.api import toolkit as traits_toolkit traits_toolkit() diff --git a/enable/savage/trait_defs/ui/svg_button_editor.py b/enable/savage/trait_defs/ui/svg_button_editor.py index 31d02aa3f..2f03cface 100644 --- a/enable/savage/trait_defs/ui/svg_button_editor.py +++ b/enable/savage/trait_defs/ui/svg_button_editor.py @@ -23,8 +23,7 @@ from traits.api import Bool, Enum, Int, Property, Range, Str, Any -from traitsui.api import View -from traitsui.basic_editor_factory import BasicEditorFactory +from traitsui.api import BasicEditorFactory, View from traitsui.ui_traits import AView # ----------------------------------------------------------------------------- diff --git a/enable/savage/trait_defs/ui/svg_editor.py b/enable/savage/trait_defs/ui/svg_editor.py index 2b7ad498e..596c9f5ce 100644 --- a/enable/savage/trait_defs/ui/svg_editor.py +++ b/enable/savage/trait_defs/ui/svg_editor.py @@ -25,8 +25,7 @@ from enable.savage.trait_defs.ui.toolkit import toolkit_object from traits.api import Property - -from traitsui.basic_editor_factory import BasicEditorFactory +from traitsui.api import BasicEditorFactory # ----------------------------------------------------------------------------- # 'SVGEditor' editor factory class: diff --git a/enable/savage/trait_defs/ui/toolkit.py b/enable/savage/trait_defs/ui/toolkit.py index da0ef7350..c0f64f810 100644 --- a/enable/savage/trait_defs/ui/toolkit.py +++ b/enable/savage/trait_defs/ui/toolkit.py @@ -24,7 +24,7 @@ def _init_toolkit(): """ # Force Traits to decide on its toolkit if it hasn't already - from traitsui.toolkit import toolkit as traits_toolkit + from traitsui.api import toolkit as traits_toolkit traits_toolkit() diff --git a/enable/tests/primitives/test_image.py b/enable/tests/primitives/test_image.py index a66a272ba..695c326f1 100644 --- a/enable/tests/primitives/test_image.py +++ b/enable/tests/primitives/test_image.py @@ -9,7 +9,7 @@ from kiva.image import GraphicsContext from traits.api import TraitError -from traits.testing.unittest_tools import UnittestTools +from traits.testing.api import UnittestTools from enable.primitives.image import Image diff --git a/enable/tests/qt4/test_scrollbar.py b/enable/tests/qt4/test_scrollbar.py index 852a73704..b670167a5 100644 --- a/enable/tests/qt4/test_scrollbar.py +++ b/enable/tests/qt4/test_scrollbar.py @@ -2,7 +2,7 @@ import unittest from enable.tests._testing import skip_if_not_qt -from pyface.gui import GUI +from pyface.api import GUI from enable.container import Container from enable.window import Window diff --git a/enable/tests/test_component_editor.py b/enable/tests/test_component_editor.py index 24276c252..b2ab42fed 100644 --- a/enable/tests/test_component_editor.py +++ b/enable/tests/test_component_editor.py @@ -3,10 +3,8 @@ import unittest from enable.component_editor import ComponentEditor -from traits.has_traits import HasTraits -from traits.trait_types import Any -from traitsui.item import Item -from traitsui.view import View +from traits.api import Any, HasTraits +from traitsui.api import Item, View from enable.tests._testing import get_dialog_size, skip_if_null diff --git a/enable/tests/tools/pyface/test_commands.py b/enable/tests/tools/pyface/test_commands.py index 8187cefa6..860a5f07f 100644 --- a/enable/tests/tools/pyface/test_commands.py +++ b/enable/tests/tools/pyface/test_commands.py @@ -10,7 +10,7 @@ from unittest.mock import MagicMock # Enthought library imports -from traits.testing.unittest_tools import UnittestTools +from traits.testing.api import UnittestTools # Local library imports from enable.component import Component diff --git a/enable/tests/tools/pyface/test_move_command_tool.py b/enable/tests/tools/pyface/test_move_command_tool.py index 0144a1c55..886385341 100644 --- a/enable/tests/tools/pyface/test_move_command_tool.py +++ b/enable/tests/tools/pyface/test_move_command_tool.py @@ -11,7 +11,7 @@ # Enthought library imports from pyface.undo.api import CommandStack -from traits.testing.unittest_tools import UnittestTools +from traits.testing.api import UnittestTools # Local library imports from enable.component import Component diff --git a/enable/tests/tools/pyface/test_resize_command_tool.py b/enable/tests/tools/pyface/test_resize_command_tool.py index 58b5d71ce..83974276e 100644 --- a/enable/tests/tools/pyface/test_resize_command_tool.py +++ b/enable/tests/tools/pyface/test_resize_command_tool.py @@ -11,7 +11,7 @@ # Enthought library imports from pyface.undo.api import CommandStack -from traits.testing.unittest_tools import UnittestTools +from traits.testing.api import UnittestTools # Local library imports from enable.component import Component diff --git a/enable/tests/tools/pyface/test_undo_tool.py b/enable/tests/tools/pyface/test_undo_tool.py index f18875da3..cbafba11b 100644 --- a/enable/tests/tools/pyface/test_undo_tool.py +++ b/enable/tests/tools/pyface/test_undo_tool.py @@ -11,7 +11,7 @@ # Enthought library imports from pyface.undo.api import UndoManager -from traits.testing.unittest_tools import UnittestTools +from traits.testing.api import UnittestTools # Local library imports from enable.base_tool import KeySpec diff --git a/enable/tests/tools/test_button_tool.py b/enable/tests/tools/test_button_tool.py index 5e19544b2..41093bcc9 100644 --- a/enable/tests/tools/test_button_tool.py +++ b/enable/tests/tools/test_button_tool.py @@ -7,7 +7,7 @@ # import unittest -from traits.testing.unittest_tools import UnittestTools +from traits.testing.api import UnittestTools from enable.component import Component from enable.testing import EnableTestAssistant diff --git a/enable/toolkit.py b/enable/toolkit.py index 99338c4fb..4f1e54d09 100644 --- a/enable/toolkit.py +++ b/enable/toolkit.py @@ -26,7 +26,7 @@ def _init_toolkit(): if not ETSConfig.toolkit: # Force Traits to decide on its toolkit if it hasn't already - from traitsui.toolkit import toolkit as traits_toolkit + from traitsui.api import toolkit as traits_toolkit traits_toolkit() diff --git a/enable/trait_defs/ui/wx/rgba_color_editor.py b/enable/trait_defs/ui/wx/rgba_color_editor.py index 4fb8668ef..4c6186b19 100644 --- a/enable/trait_defs/ui/wx/rgba_color_editor.py +++ b/enable/trait_defs/ui/wx/rgba_color_editor.py @@ -21,9 +21,8 @@ from traits.api import Bool from traits.trait_base import SequenceTypes -from traitsui.api import View +from traitsui.api import EditorFactory, View from traitsui.wx.editor import Editor -from traitsui.editor_factory import EditorFactory from traitsui.wx.editor_factory import ReadonlyEditor from traitsui.wx.helper import position_window