diff --git a/traits/has_traits.py b/traits/has_traits.py index e8e3222ec..507e69c7d 100644 --- a/traits/has_traits.py +++ b/traits/has_traits.py @@ -25,7 +25,6 @@ from types import FunctionType from . import __version__ as TraitsVersion -from .adaptation.adaptation_error import AdaptationError from .constants import DefaultValue, TraitKind from .ctrait import CTrait, __newobj__ from .ctraits import CHasTraits @@ -3679,26 +3678,11 @@ def _veto_changed(self, state): class MetaInterface(ABCMetaHasTraits): """ Meta class for interfaces. - Interfaces are simple ABCs with the following features:- - - 1) They cannot be instantiated (they are interfaces, not implementations!). - 2) Calling them is equivalent to calling 'adapt'. - + Historically, there were some differences between interfaces + and ABCs in Traits, but now Interface is a near synonym for + ABCHasTraits. """ - @deprecated('use "adapt(adaptee, protocol)" instead.') - def __call__(self, adaptee, default=AdaptationError): - """ Attempt to adapt the adaptee to this interface. - - Note that this means that (intentionally ;^) that interfaces - cannot be instantiated! - - """ - - from traits.adaptation.api import adapt - - return adapt(adaptee, self, default=default) - class Interface(HasTraits, metaclass=MetaInterface): """ The base class for all interfaces. diff --git a/traits/tests/test_interface_checker.py b/traits/tests/test_interface_checker.py index d6e594ccd..6707b585c 100644 --- a/traits/tests/test_interface_checker.py +++ b/traits/tests/test_interface_checker.py @@ -12,11 +12,11 @@ # Standard library imports. import unittest -import warnings # Enthought library imports. from traits.adaptation.api import reset_global_adaptation_manager from traits.api import ( + adapt, Adapter, HasTraits, Instance, @@ -386,17 +386,7 @@ class Foo(HasTraits): f = Foo() - # Adaptation via direct instantiation of interfaces is deprecated, so - # catch the warning to keep the test run output clean. - with warnings.catch_warnings(record=True) as warn_msgs: - warnings.simplefilter("always", DeprecationWarning) - self.assertEqual(f, IFoo(f)) - - self.assertEqual(len(warn_msgs), 1) - warn_msg = warn_msgs[0] - self.assertIn( - 'use "adapt(adaptee, protocol)" instead', str(warn_msg.message)) - self.assertIn("test_interface_checker", warn_msg.filename) + self.assertEqual(f, adapt(f, IFoo)) def test_adaptation(self): """ adaptation """ @@ -415,17 +405,8 @@ class FooToIFooAdapter(Adapter): f = Foo() - # Make sure adaptation works. Adaptation via direct instantiation of - # Interface classes is deprecated, so suppress the warning. - with warnings.catch_warnings(record=True) as warn_msgs: - warnings.simplefilter("always", DeprecationWarning) - i_foo = IFoo(f) + # Make sure adaptation works. + i_foo = adapt(f, IFoo) - self.assertNotEqual(None, i_foo) + self.assertIsNotNone(i_foo) self.assertEqual(FooToIFooAdapter, type(i_foo)) - - self.assertEqual(len(warn_msgs), 1) - warn_msg = warn_msgs[0] - self.assertIn( - 'use "adapt(adaptee, protocol)" instead', str(warn_msg.message)) - self.assertIn("test_interface_checker", warn_msg.filename)