ipython / ipython/traitlets

Instance trait type default value confusion

Abierto
#315 5 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
653
Forks
217
Merge medio
2 d 21 h
PR fusionados (30 d)
2

Descripción

We raise here:

``` python
class A(HasTraits):
inst = Instance(Foo)

A().inst
```

But not here:

``` python
class A(HasTraits):
inst = Instance(Foo, allow_none=True)

A().inst
```

This seems magical, and is not at all implied by `allow_none=True`.

We should probably try to enforce this convention:

``` python
class A(HasTraits):
inst = Instance(Foo, default_value=None, allow_none=True)

A().inst
```

Or at the very least:

set `allow_none=True` if `default_value=None`

``` python
class A(HasTraits):
inst = Instance(Foo, default_value=None)

A().inst
```

This isn't backwards compatible, but IMO it resolves a bug.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.