@@ -22,29 +22,31 @@ _.extend(BaseType.prototype, {
22
22
} ,
23
23
} )
24
24
25
- function ThreeType ( typeName ) {
25
+ function ThreeType ( typeName , nullable = true ) {
26
26
this . typeName = typeName ;
27
27
this . defaultValue = null ;
28
28
this . serialize = true ;
29
+ this . nullable = nullable ;
29
30
}
30
31
_ . extend ( ThreeType . prototype , BaseType . prototype , {
31
32
getTraitlet : function ( ) {
33
+ var nullableStr = this . nullable ? 'True' : 'False' ;
32
34
// allow type unions
33
35
if ( this . typeName instanceof Array ) {
34
36
// TODO: only instan
35
37
var instances = this . typeName . map ( function ( typeName ) {
36
- return ' Instance(' + typeName + ', allow_none=True).tag(sync=True, **widget_serialization )' ;
38
+ return ' Instance(' + typeName + ', allow_none=' + nullableStr + ' )';
37
39
} ) ;
38
- return 'Union([\n' + instances . join ( ',\n' ) + '\n ])' ;
40
+ return 'Union([\n' + instances . join ( ',\n' ) + '\n ]).tag(sync=True, **widget_serialization) ' ;
39
41
40
42
// return 'Any()';
41
43
}
42
44
43
45
if ( this . typeName . toLowerCase ( ) === 'this' ) {
44
46
return 'This().tag(sync=True, **widget_serialization)' ;
45
47
}
46
-
47
- return 'Instance(' + this . typeName + ', allow_none=True ).tag(sync=True, **widget_serialization)' ;
48
+
49
+ return 'Instance(' + this . typeName + ', allow_none=' + nullableStr + ' ).tag(sync=True, **widget_serialization)';
48
50
} ,
49
51
getPropArrayName : function ( ) {
50
52
return 'three_properties' ;
0 commit comments