enthought / enthought/traits

Interfaces does not check traits types

Open
#384 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

I'm experimenting with Interfaces, and I noticed that `@provides` does not check for traits types:

```python
from traits.api import Interface, Array, Float, HasTraits, provides
import traits

traits.has_traits.CHECK_INTERFACES = 2

class MyInterface(Interface):

trait1 = Array(shape=[None,2])
trait2 = Float()

@provides(MyInterface)
class TestClass1(HasTraits):
trait1 = Array(shape=[10,2])
trait2 = Float()

# This I expect to work, and it does.

@provides(MyInterface)
class TestClass2(HasTraits):

trait1 = Array(shape=[10,4])
trait2 = Float()

# This I don't expect to fail, but it does not.

@provides(MyInterface)
class TestClass2(HasTraits):

trait1 = Float()
trait2 = Float()

# This I don't expect to fail either, but it does not.
```

Did I miss something ? What would it take to make traits type compatibility checking work ?

Thanks for this very nice library, by the way.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.