Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some missing stubs #1204

Merged
merged 6 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion traits-stubs/traits-stubs/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
#
mdickinson marked this conversation as resolved.
Show resolved Hide resolved
# 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,
Expand All @@ -18,9 +27,30 @@ from .traits import (
Trait as Trait
)

from .ctrait import CTrait as CTrait
rahulporuri marked this conversation as resolved.
Show resolved Hide resolved

from .has_traits import (
ABCHasStrictTraits as ABCHasStrictTraits,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these aren't alphabetized; for ease of comparison, I'm using the same order as is currently in api.py.

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 (
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 0 additions & 13 deletions traits-stubs/traits-stubs/base_trait_hander.pyi

This file was deleted.

4 changes: 2 additions & 2 deletions traits-stubs/traits-stubs/trait_handler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
...
...
17 changes: 17 additions & 0 deletions traits-stubs/traits_stubs_tests/examples/HasStrictTraits.py
Original file line number Diff line number Diff line change
@@ -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")
15 changes: 15 additions & 0 deletions traits-stubs/traits_stubs_tests/examples/Interface.py
Original file line number Diff line number Diff line change
@@ -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))