Skip to content

Commit 13fbe9e

Browse files
committed
Fix optional typescript enums when generating component props
1 parent 95a3f99 commit 13fbe9e

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

dash/development/_generate_prop_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def generate_any(*_):
6868

6969

7070
def generate_enum(prop_info):
71-
values = str([v["value"] for v in prop_info["value"]])
71+
values = str([v.get("value") for v in prop_info["value"]])
7272
return f"pt.oneOf({values})"
7373

7474

dash/development/_jl_components_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def shape_or_exact():
151151
node=lambda: "a list of or a singular dash component, string or number",
152152
# React's PropTypes.oneOf
153153
enum=lambda: "a value equal to: {}".format(
154-
", ".join("{}".format(str(t["value"])) for t in type_object["value"])
154+
", ".join("{}".format(str(t.get("value"))) for t in type_object["value"])
155155
),
156156
# React's PropTypes.oneOfType
157157
union=lambda: "{}".format(

dash/development/_py_components_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ def tuple_of():
685685
# React's PropTypes.oneOf
686686
enum=lambda: (
687687
"a value equal to: "
688-
+ ", ".join(str(t["value"]) for t in type_object["value"])
688+
+ ", ".join(str(t.get("value")) for t in type_object["value"])
689689
),
690690
# React's PropTypes.oneOfType
691691
union=lambda: " | ".join(

dash/development/_py_prop_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _get_literal_value(value):
136136

137137

138138
def generate_enum(type_info, *_):
139-
values = [_get_literal_value(v["value"]) for v in type_info["value"] if v]
139+
values = [_get_literal_value(v.get("value")) for v in type_info["value"] if v]
140140
return f"Literal[{', '.join(values)}]"
141141

142142

dash/development/_r_components_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ def shape_or_exact():
879879
node=lambda: "a list of or a singular dash component, string or number",
880880
# React's PropTypes.oneOf
881881
enum=lambda: "a value equal to: {}".format(
882-
", ".join("{}".format(str(t["value"])) for t in type_object["value"])
882+
", ".join("{}".format(str(t.get("value"))) for t in type_object["value"])
883883
),
884884
# React's PropTypes.oneOfType
885885
union=lambda: "{}".format(

0 commit comments

Comments
 (0)