Skip to content

Commit 69d134f

Browse files
committed
Add wildcard * support for custom prop typing
1 parent 3446248 commit 69d134f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

dash/development/_py_components_generation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ def generate_class_file(
250250
custom_typing_module,
251251
)
252252

253-
custom_imp = get_custom_imports(custom_typing_module).get(typename)
253+
custom_imp = get_custom_imports(custom_typing_module)
254+
custom_imp = custom_imp.get(typename) or custom_imp.get("*")
255+
254256
if custom_imp:
255257
imports += "\n".join(custom_imp)
256258
imports += "\n\n"

dash/development/_py_prop_typing.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ def generate_enum(type_info, *_):
140140
return f"Literal[{', '.join(values)}]"
141141

142142

143+
def _get_custom_prop(custom_props, component_name, prop_name):
144+
customs = custom_props.get(component_name) or custom_props.get("*", {})
145+
return customs.get(prop_name)
146+
147+
143148
def get_prop_typing(
144149
type_name: str,
145150
component_name: str,
@@ -153,7 +158,7 @@ def get_prop_typing(
153158
return "typing.Union[str, dict]"
154159

155160
if custom_props:
156-
special = custom_props.get(component_name, {}).get(prop_name)
161+
special = _get_custom_prop(custom_props, component_name, prop_name)
157162
if special:
158163
return special(type_info, component_name, prop_name)
159164

0 commit comments

Comments
 (0)