33import datetime as dt
44import uuid
55from decimal import Decimal
6- from typing import Annotated , Any
6+ from typing import Annotated , Any , Union
77
88from amazonorders .session import AmazonSession
99from amazonorders .transactions import AmazonTransactions
@@ -27,12 +27,12 @@ class Entity(BaseClone, abc.ABC):
2727class Item (Entity ):
2828 title : str
2929 link : HttpUrl
30- price : Decimal | None = None
31- seller : AmazonSellerType | None = None
32- condition : str | None = None
33- return_eligible_date : dt .date | None = None
34- image_link : HttpUrl | None = None
35- quantity : int | None = None
30+ price : Union [ Decimal , None ] = None
31+ seller : Union [ AmazonSellerType , None ] = None
32+ condition : Union [ str , None ] = None
33+ return_eligible_date : Union [ dt .date , None ] = None
34+ image_link : Union [ HttpUrl , None ] = None
35+ quantity : Union [ int , None ] = None
3636
3737 def __str__ (self ) -> str :
3838 if settings .ynab_use_markdown :
@@ -59,15 +59,15 @@ def address_from_str(cls, data: Any) -> Any:
5959
6060class Recipient (Entity ):
6161 name : str
62- address : Address | None = Field (
62+ address : Union [ Address , None ] = Field (
6363 repr = False , default = None , description = "not parsed properly, don't use"
6464 )
6565
6666
6767class Shipment (Entity ):
6868 items : list [Item ]
69- delivery_status : str | None = None
70- tracking_link : HttpUrl | None = None
69+ delivery_status : Union [ str , None ] = None
70+ tracking_link : Union [ HttpUrl , None ] = None
7171
7272
7373class Order (Entity ):
@@ -77,24 +77,24 @@ class Order(Entity):
7777 shipments : list [Shipment ]
7878 items : list [Item ]
7979 order_number : str
80- order_details_link : HttpUrl | None = None
80+ order_details_link : Union [ HttpUrl , None ] = None
8181 grand_total : Decimal
8282 order_placed_date : dt .date
83- recipient : Recipient | None = None
84- payment_method : str | None = None
85- payment_method_last_4 : str | None = None
86- total_before_tax : Decimal | None = None
83+ recipient : Union [ Recipient , None ] = None
84+ payment_method : Union [ str , None ] = None
85+ payment_method_last_4 : Union [ str , None ] = None
86+ total_before_tax : Union [ Decimal , None ] = None
8787
8888
8989class Orders (SimpleDict [str , Order ]):
9090 @classmethod
9191 def get_order_history (
9292 cls ,
9393 config : AmazonConfig ,
94- session : AmazonSession | None = None ,
95- years : list [int ] | int | None = None ,
94+ session : Union [ AmazonSession , None ] = None ,
95+ years : Union [ list [int ], Union [ int , None ]] = None ,
9696 * ,
97- debug : bool | None = None ,
97+ debug : Union [ bool , None ] = None ,
9898 ):
9999 from ynamazon .amazon_transactions import (
100100 _fetch_amazon_order_history , # pyright: ignore[reportPrivateUsage]
@@ -121,14 +121,18 @@ class Transaction(Entity):
121121 order_number : str
122122 order_details_link : HttpUrl
123123 seller_name : Annotated [str , Field (alias = "seller" )]
124- order : Order | None = None
124+ order : Union [ Order , None ] = None
125125
126126 def match_order (self , orders : Orders ) -> None :
127127 """Matches the transaction with the order."""
128128 self .order = orders .get (self .order_number )
129129
130130 def getattr_path (
131- self , attr_path : str , * , separator : str = "__" , default : Any | Missing = MISSING
131+ self ,
132+ attr_path : str ,
133+ * ,
134+ separator : str = "__" ,
135+ default : Union [Any , Missing ] = MISSING ,
132136 ) -> Any :
133137 return getattr_path (self , attr_path , separator = separator , default = default )
134138
0 commit comments