array attribute is either True or None
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
The `array` attribute is documented to be a boolean which indicates if a trait is an array. However, it appears that it is actually only a boolean when a trait is an array, and is otherwise `None`. Example code (using `traits` 4.6.0):
```python
from traits.api import Array, String, Int
class Obj:
a = Array()
s = String()
i = Int()
o = Obj()
print(repr(o.a.array))
print(repr(o.s.array))
print(repr(o.i.array))
```
Output:
```
True
None
None
```
This works in a case where you might do something like:
```python
if thing.array:
# do stuff
else:
# do other stuff
```
but in general it is not good practice to rely on the `False`-like nature of `None`. It would be better for the `array` attribute to always be defined, defaulting to `False` except for actual array types.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.