Skip to content

Commit

Permalink
Replace | with Union
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-el committed Aug 21, 2024
1 parent 223fa17 commit 2ca6134
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions snowplow_tracker/events/structured_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# language governing permissions and limitations there under.
# """
from snowplow_tracker.events.event import Event
from typing import Optional, List
from typing import Optional, List, Union
from snowplow_tracker.subject import Subject
from snowplow_tracker.self_describing_json import SelfDescribingJson
from snowplow_tracker.contracts import non_empty_string
Expand Down Expand Up @@ -129,12 +129,12 @@ def property_(self, value: str):
self.payload.add("se_pr", value)

@property
def value(self) -> Optional[int | float]:
def value(self) -> Optional[Union[int, float]]:
"""
A value associated with the user action
"""
return self.payload.nv_pairs.get("se_va")

@value.setter
def value(self, value: int | float):
def value(self, value: Union[int, float]):
self.payload.add("se_va", value)
14 changes: 8 additions & 6 deletions snowplow_tracker/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def track_add_to_cart(
)
non_empty_string(sku)

properties: dict[str, str | float | int] = {}
properties: Union[dict[str, Union[str, float, int]]] = {}
properties["sku"] = sku
properties["quantity"] = quantity
if name is not None:
Expand Down Expand Up @@ -427,7 +427,7 @@ def track_remove_from_cart(
)
non_empty_string(sku)

properties: dict[str, str | float | int] = {}
properties: dict[str, Union[str, float, int]] = {}
properties["sku"] = sku
properties["quantity"] = quantity
if name is not None:
Expand Down Expand Up @@ -495,7 +495,7 @@ def track_form_change(
if type_ is not None:
one_of(type_.lower(), FORM_TYPES)

properties: dict[str, Optional[str] | ElementClasses] = dict()
properties: dict[str, Union[Optional[str], ElementClasses]] = dict()
properties["formId"] = form_id
properties["elementId"] = element_id
properties["nodeName"] = node_name
Expand Down Expand Up @@ -552,7 +552,7 @@ def track_form_submit(
form_element(element)

properties: dict[
str, str | ElementClasses | FormClasses | List[Dict[str, Any]]
str, Union[str, ElementClasses, FormClasses, List[Dict[str, Any]]]
] = dict()
properties["formId"] = form_id
if form_classes is not None:
Expand Down Expand Up @@ -606,7 +606,9 @@ def track_site_search(
)
non_empty(terms)

properties: dict[str, Sequence[str] | dict[str, str | bool] | int] = {}
properties: Union[
dict[str, Sequence[str], dict[str, Union[str, bool]], int]
] = {}
properties["terms"] = terms
if filters is not None:
properties["filters"] = filters
Expand Down Expand Up @@ -882,7 +884,7 @@ def track_struct_event(
action: str,
label: Optional[str] = None,
property_: Optional[str] = None,
value: Optional[int | float] = None,
value: Optional[Union[int, float]] = None,
context: Optional[List[SelfDescribingJson]] = None,
tstamp: Optional[float] = None,
event_subject: Optional[Subject] = None,
Expand Down

0 comments on commit 2ca6134

Please sign in to comment.