enthought / enthought/traits

`copy_traits` failing with `List(This)` traits

Open
#1,010 3 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Ran into this issue while writing some tests for our library.

`copy_traits` seems to have an error when copying traits that are defined as `List(This)`.

Here's a minimal working example to demonstrate this behavior (using `clone_traits` for convenience but the bug is really in `copy_traits`):
```python
from traits.api import *

class Node(HasTraits):
children = List(This)

node = Node(children=[Node(), Node()])

assert len(node.children) == 2
assert len(node.clone_traits().children) == 0
assert len(node.clone_traits(copy='shallow').children) == 0
assert len(node.clone_traits(copy='deep').children) == 0
```

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.