diff --git a/traits-stubs/traits-stubs/api.pyi b/traits-stubs/traits-stubs/api.pyi index 57b1f1083..833f8bd4b 100644 --- a/traits-stubs/traits-stubs/api.pyi +++ b/traits-stubs/traits-stubs/api.pyi @@ -8,7 +8,16 @@ # # Thanks for using Enthought open source! -from .trait_type import TraitType as TraitType +from .constants import ( + ComparisonMode as ComparisonMode, + DefaultValue as DefaultValue, + TraitKind as TraitKind, + ValidateTrait as ValidateTrait, + NO_COMPARE as NO_COMPARE, + OBJECT_IDENTITY_COMPARE as OBJECT_IDENTITY_COMPARE, + RICH_COMPARE as RICH_COMPARE, +) + from .traits import ( Color as Color, Default as Default, @@ -18,9 +27,30 @@ from .traits import ( Trait as Trait ) +from .ctrait import CTrait as CTrait + from .has_traits import ( + ABCHasStrictTraits as ABCHasStrictTraits, + ABCHasTraits as ABCHasTraits, + ABCMetaHasTraits as ABCMetaHasTraits, + AbstractViewElement as AbstractViewElement, HasTraits as HasTraits, + HasStrictTraits as HasStrictTraits, + HasPrivateTraits as HasPrivateTraits, + HasRequiredTraits as HasRequiredTraits, + Interface as Interface, + SingletonHasTraits as SingletonHasTraits, + SingletonHasStrictTraits as SingletonHasStrictTraits, + SingletonHasPrivateTraits as SingletonHasPrivateTraits, + MetaHasTraits as MetaHasTraits, + Vetoable as Vetoable, + VetoableEvent as VetoableEvent, observe as observe, + on_trait_change as on_trait_change, + cached_property as cached_property, + property_depends_on as property_depends_on, + provides as provides, + isinterface as isinterface, ) from .trait_types import ( @@ -146,6 +176,9 @@ from .trait_types import ( ValidatedTuple as ValidatedTuple ) +from .base_trait_handler import BaseTraitHandler as BaseTraitHandler +from .trait_handler import TraitHandler as TraitHandler +from .trait_type import TraitType as TraitType from .trait_handlers import ( TraitCoerceType as TraitCoerceType, TraitCastType as TraitCastType, diff --git a/traits-stubs/traits-stubs/base_trait_hander.pyi b/traits-stubs/traits-stubs/base_trait_hander.pyi deleted file mode 100644 index 3e9b1671f..000000000 --- a/traits-stubs/traits-stubs/base_trait_hander.pyi +++ /dev/null @@ -1,13 +0,0 @@ -# (C) Copyright 2005-2020 Enthought, Inc., Austin, TX -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in LICENSE.txt and may be redistributed only under -# the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# -# Thanks for using Enthought open source! - - -class BaseTraitHandler(object): - ... diff --git a/traits-stubs/traits-stubs/trait_handler.pyi b/traits-stubs/traits-stubs/trait_handler.pyi index 02b463ccc..d0f24c8b3 100644 --- a/traits-stubs/traits-stubs/trait_handler.pyi +++ b/traits-stubs/traits-stubs/trait_handler.pyi @@ -8,8 +8,8 @@ # # Thanks for using Enthought open source! -from .base_trait_hander import BaseTraitHandler +from .base_trait_handler import BaseTraitHandler class TraitHandler(BaseTraitHandler): - ... \ No newline at end of file + ... diff --git a/traits-stubs/traits_stubs_tests/examples/HasStrictTraits.py b/traits-stubs/traits_stubs_tests/examples/HasStrictTraits.py new file mode 100644 index 000000000..ccb19f878 --- /dev/null +++ b/traits-stubs/traits_stubs_tests/examples/HasStrictTraits.py @@ -0,0 +1,17 @@ +from traits.api import Event, HasStrictTraits, observe + + +class Person(HasStrictTraits): + conductor = Event() + + @observe("conductor") + def talk(self, event): + pass + + +def sing(event): + pass + + +person = Person() +person.observe(sing, "conductor") diff --git a/traits-stubs/traits_stubs_tests/examples/Interface.py b/traits-stubs/traits_stubs_tests/examples/Interface.py new file mode 100644 index 000000000..660fb6400 --- /dev/null +++ b/traits-stubs/traits_stubs_tests/examples/Interface.py @@ -0,0 +1,15 @@ +from traits.api import Float, HasTraits, Interface, provides, Str, Tuple + + +class IHasName(Interface): + name = Str() + + +@provides(IHasName) +class NamedColor(HasTraits): + name = Str() + + rgb = Tuple(Float, Float, Float) + + +named_color = NamedColor(name="green", rgb=(0.0, 1.0, 0.0))