Skip to content

Commit

Permalink
[flows] defaulting action's payload to empty dict
Browse files Browse the repository at this point in the history
  • Loading branch information
david-lev committed Dec 14, 2024
1 parent a31f0d7 commit 2c3f903
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 54 deletions.
12 changes: 9 additions & 3 deletions pywa/types/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3270,7 +3270,9 @@ class DataExchangeAction(BaseAction):
name: FlowActionType = dataclasses.field(
default=FlowActionType.DATA_EXCHANGE, init=False, repr=False
)
payload: dict[str, str | bool | Iterable[DataSource] | ScreenDataRef | ComponentRef]
payload: dict[
str, str | bool | Iterable[DataSource] | ScreenDataRef | ComponentRef
] = dataclasses.field(default_factory=dict)


@dataclasses.dataclass(slots=True, kw_only=True)
Expand All @@ -3297,7 +3299,9 @@ class NavigateAction(BaseAction):
default=FlowActionType.NAVIGATE, init=False, repr=False
)
next: Next
payload: dict[str, str | bool | Iterable[DataSource] | ScreenDataRef | ComponentRef]
payload: dict[
str, str | bool | Iterable[DataSource] | ScreenDataRef | ComponentRef
] = dataclasses.field(default_factory=dict)


@dataclasses.dataclass(slots=True, kw_only=True)
Expand Down Expand Up @@ -3374,4 +3378,6 @@ class CompleteAction(BaseAction):
name: FlowActionType = dataclasses.field(
default=FlowActionType.COMPLETE, init=False, repr=False
)
payload: dict[str, str | bool | ScreenDataRef | ComponentRef]
payload: dict[str, str | bool | ScreenDataRef | ComponentRef] = dataclasses.field(
default_factory=dict
)
10 changes: 1 addition & 9 deletions tests/data/flows/2_1/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@
text="Don't have an account? Sign up",
on_click_action=NavigateAction(
next=Next(type=NextType.SCREEN, name="SIGN_UP"),
payload={},
),
),
EmbeddedLink(
Expand Down Expand Up @@ -641,7 +640,6 @@
type=NextType.SCREEN,
name="TERMS_AND_CONDITIONS",
),
payload={},
),
),
offers_acceptance := OptIn(
Expand Down Expand Up @@ -788,7 +786,6 @@
type=NextType.SCREEN,
name="TERMS_AND_CONDITIONS",
),
payload={},
),
),
offers_acceptance := OptIn(
Expand Down Expand Up @@ -932,7 +929,6 @@
type=NextType.SCREEN,
name="BOOKING_DETAILS",
),
payload={},
),
),
],
Expand Down Expand Up @@ -1022,14 +1018,11 @@
type=NextType.SCREEN,
name="TERMS_AND_CONDITIONS",
),
payload={},
),
),
Footer(
label="Confirm booking",
on_click_action=DataExchangeAction(
payload={},
),
on_click_action=DataExchangeAction(),
),
],
)
Expand Down Expand Up @@ -1230,7 +1223,6 @@
type=NextType.SCREEN,
name="TERMS_AND_CONDITIONS",
),
payload={},
),
),
Footer(
Expand Down
10 changes: 3 additions & 7 deletions tests/data/flows/4_0/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
),
Footer(
label="Complete",
on_click_action=CompleteAction(payload={}),
on_click_action=CompleteAction(),
),
]
),
Expand Down Expand Up @@ -59,7 +59,7 @@
),
Footer(
label="Complete",
on_click_action=CompleteAction(payload={}),
on_click_action=CompleteAction(),
),
]
),
Expand Down Expand Up @@ -179,9 +179,7 @@
),
Footer(
label="Continue",
on_click_action=DataExchangeAction(
payload={},
),
on_click_action=DataExchangeAction(),
),
],
)
Expand All @@ -207,7 +205,6 @@
label="CTA",
on_click_action=NavigateAction(
next=Next(name="SCREEN_TWO"),
payload={},
),
),
],
Expand Down Expand Up @@ -300,7 +297,6 @@
text="Choose insurance type",
on_click_action=NavigateAction(
next=Next(type=NextType.SCREEN, name="SELECT_INSURANCE"),
payload={},
),
),
Footer(
Expand Down
4 changes: 2 additions & 2 deletions tests/data/flows/5_0/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
),
Footer(
label="Continue",
on_click_action=CompleteAction(payload={}),
on_click_action=CompleteAction(),
),
],
),
Expand Down Expand Up @@ -82,7 +82,7 @@
),
Footer(
label="Continue",
on_click_action=DataExchangeAction(payload={}),
on_click_action=DataExchangeAction(),
),
],
),
Expand Down
3 changes: 1 addition & 2 deletions tests/data/flows/5_1/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
label="RichText can be used to render large static or dynamic texts.",
on_click_action=NavigateAction(
next=Next(name="TOC"),
payload={},
),
),
Footer(
label="Proceed",
on_click_action=CompleteAction(payload={}),
on_click_action=CompleteAction(),
),
],
),
Expand Down
20 changes: 5 additions & 15 deletions tests/data/flows/6_0/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
),
Footer(
label="Footer",
on_click_action=CompleteAction(
payload={},
),
on_click_action=CompleteAction(),
),
],
),
Expand Down Expand Up @@ -63,9 +61,7 @@
),
Footer(
label="Footer",
on_click_action=CompleteAction(
payload={},
),
on_click_action=CompleteAction(),
),
],
),
Expand Down Expand Up @@ -284,9 +280,7 @@
),
Footer(
label="Complete",
on_click_action=CompleteAction(
payload={},
),
on_click_action=CompleteAction(),
),
],
),
Expand Down Expand Up @@ -326,9 +320,7 @@
),
Footer(
label="Static footer label",
on_click_action=CompleteAction(
payload={},
),
on_click_action=CompleteAction(),
),
],
),
Expand Down Expand Up @@ -358,9 +350,7 @@
),
Footer(
label="Static footer label",
on_click_action=CompleteAction(
payload={},
),
on_click_action=CompleteAction(),
),
],
),
Expand Down
8 changes: 2 additions & 6 deletions tests/data/flows/6_1/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
),
Footer(
label="Continue",
on_click_action=DataExchangeAction(
payload={},
),
on_click_action=DataExchangeAction(),
),
],
),
Expand Down Expand Up @@ -105,9 +103,7 @@
),
Footer(
label="Continue",
on_click_action=DataExchangeAction(
payload={},
),
on_click_action=DataExchangeAction(),
),
],
),
Expand Down
11 changes: 1 addition & 10 deletions tests/data/flows/6_2/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
),
Footer(
label="Continue",
on_click_action=CompleteAction(payload={}),
on_click_action=CompleteAction(),
),
],
),
Expand Down Expand Up @@ -71,7 +71,6 @@
),
on_click_action=NavigateAction(
next=Next(name="SECOND_SCREEN"),
payload={},
),
),
NavigationItem(
Expand All @@ -85,7 +84,6 @@
),
on_click_action=NavigateAction(
next=Next(name="SECOND_SCREEN"),
payload={},
),
),
NavigationItem(
Expand All @@ -99,7 +97,6 @@
),
on_click_action=NavigateAction(
next=Next(name="FOURTH_SCREEN"),
payload={},
),
),
NavigationItem(
Expand All @@ -113,7 +110,6 @@
),
on_click_action=NavigateAction(
next=Next(name="FIFTH_SCREEN"),
payload={},
),
),
NavigationItem(
Expand Down Expand Up @@ -173,7 +169,6 @@
label="Continue",
on_click_action=NavigateAction(
next=Next(name="CONTACT"),
payload={},
),
),
],
Expand Down Expand Up @@ -222,7 +217,6 @@
label="Next",
on_click_action=NavigateAction(
next=Next(name="CONTACT"),
payload={},
),
),
],
Expand Down Expand Up @@ -274,7 +268,6 @@
label="Next",
on_click_action=NavigateAction(
next=Next(name="CONTACT"),
payload={},
),
),
],
Expand Down Expand Up @@ -413,7 +406,6 @@
label="Continue",
on_click_action=NavigateAction(
next=Next(name="CONTACT"),
payload={},
),
),
],
Expand Down Expand Up @@ -462,7 +454,6 @@
label="Next",
on_click_action=NavigateAction(
next=Next(name="CONTACT"),
payload={},
),
),
],
Expand Down

0 comments on commit 2c3f903

Please sign in to comment.