@@ -21,14 +21,18 @@ def get_typing_type(plotly_type, array_ok=False):
21
21
str
22
22
Python type string
23
23
"""
24
- if plotly_type in ('data_array' , 'info_array' , 'colorlist' ):
25
- pytype = 'List'
24
+ if plotly_type == 'data_array' :
25
+ pytype = 'numpy.ndarray'
26
+ elif plotly_type == 'info_array' :
27
+ pytype = 'list'
28
+ elif plotly_type == 'colorlist' :
29
+ pytype = 'list'
26
30
elif plotly_type in ('string' , 'color' , 'colorscale' , 'subplotid' ):
27
31
pytype = 'str'
28
32
elif plotly_type in ('enumerated' , 'flaglist' , 'any' ):
29
33
pytype = 'Any'
30
34
elif plotly_type in ('number' , 'angle' ):
31
- pytype = 'Number '
35
+ pytype = 'int|float '
32
36
elif plotly_type == 'integer' :
33
37
pytype = 'int'
34
38
elif plotly_type == 'boolean' :
@@ -37,7 +41,7 @@ def get_typing_type(plotly_type, array_ok=False):
37
41
raise ValueError ('Unknown plotly type: %s' % plotly_type )
38
42
39
43
if array_ok :
40
- return f'Union[ { pytype } , List[ { pytype } ]] '
44
+ return f'{ pytype } |numpy.ndarray '
41
45
else :
42
46
return pytype
43
47
@@ -85,14 +89,6 @@ def build_datatype_py(node):
85
89
f'from plotly.validators{ node .parent_dotpath_str } import '
86
90
f'{ undercase } as v_{ undercase } \n ' )
87
91
88
- # ### Import type's graph_objs package with rename ###
89
- # If type has any compound children, then import that package that
90
- # holds them
91
- if node .child_compound_datatypes :
92
- buffer .write (
93
- f'from plotly.graph_objs{ node .parent_dotpath_str } import '
94
- f'{ undercase } as d_{ undercase } \n ' )
95
-
96
92
# Write class definition
97
93
# ----------------------
98
94
buffer .write (f"""
@@ -104,13 +100,16 @@ class {datatype_class}({node.name_base_datatype}):\n""")
104
100
105
101
subtype_nodes = child_datatype_nodes
106
102
for subtype_node in subtype_nodes :
107
- sub_datatype_class = subtype_node .name_datatype_class
108
103
if subtype_node .is_array_element :
109
- prop_type = f'Tuple[d_{ undercase } .{ sub_datatype_class } ]'
104
+ prop_type = (f"tuple[plotly.graph_objs{ node .dotpath_str } ." +
105
+ f"{ subtype_node .name_datatype_class } ]" )
106
+
110
107
elif subtype_node .is_compound :
111
- prop_type = f'd_{ undercase } .{ sub_datatype_class } '
108
+ prop_type = (f"plotly.graph_objs{ node .dotpath_str } ." +
109
+ f"{ subtype_node .name_datatype_class } " )
112
110
else :
113
- prop_type = get_typing_type (subtype_node .datatype )
111
+ prop_type = get_typing_type (
112
+ subtype_node .datatype , subtype_node .is_array_ok )
114
113
115
114
# #### Get property description ####
116
115
raw_description = subtype_node .description
@@ -142,9 +141,13 @@ class {datatype_class}({node.name_base_datatype}):\n""")
142
141
# { subtype_node .name_property }
143
142
# { '-' * len (subtype_node .name_property )}
144
143
@property
145
- def { subtype_node .name_property } (self) -> { prop_type } :
144
+ def { subtype_node .name_property } (self):
146
145
\" \" \"
147
146
{ property_docstring }
147
+
148
+ Returns
149
+ -------
150
+ { prop_type }
148
151
\" \" \"
149
152
return self['{ subtype_node .name_property } ']""" )
150
153
0 commit comments