@@ -102,9 +102,9 @@ def __init__(
102
102
prop_keys = list (props .keys ())
103
103
if "children" in props and "children" in list_of_valid_keys :
104
104
prop_keys .remove ("children" )
105
- default_argtext = (
106
- f"children: { get_prop_typing ( 'node' , '' , '' , {}) } = None, \n "
107
- )
105
+ # TODO For dash 3.0, remove the Optional and = None for proper typing.
106
+ # Also add the other required props after children.
107
+ default_argtext = f"children: typing.Optional[ { get_prop_typing ( 'node' , '' , '' , {}) } ] = None, \n "
108
108
args = "{k: _locals[k] for k in _explicit_args if k != 'children'}"
109
109
argtext = "children=children, **args"
110
110
else :
@@ -138,21 +138,19 @@ def __init__(
138
138
or prop_key == "setProps"
139
139
):
140
140
continue
141
- required = prop .get ("required" )
142
- type_info = prop .get ("type" )
143
141
144
- default_value = "Component.REQUIRED" if required else "Component.UNDEFINED"
142
+ type_info = prop . get ( "type" )
145
143
146
144
if not type_info :
147
145
print (f"Invalid prop type for typing: { prop_key } " )
148
- default_arglist .append (f"{ prop_key } = { default_value } " )
146
+ default_arglist .append (f"{ prop_key } = None " )
149
147
continue
150
148
151
149
type_name = type_info .get ("name" )
152
150
153
151
typed = get_prop_typing (type_name , typename , prop_key , type_info , namespace )
154
152
155
- arg_value = f"{ prop_key } : { typed } = { default_value } "
153
+ arg_value = f"{ prop_key } : typing.Optional[ { typed } ] = None "
156
154
157
155
default_arglist .append (arg_value )
158
156
0 commit comments