@@ -36,19 +36,19 @@ def get_items_request(amazon_api, asin_chunk: List[str], **kwargs) -> GetItemsRe
3636 marketplace = amazon_api .marketplace ,
3737 partner_tag = amazon_api .tag ,
3838 item_ids = asin_chunk ,
39- ** kwargs
39+ ** kwargs ,
4040 )
41- except TypeError as e :
41+ except TypeError as exc :
4242 raise MalformedRequestException (
43- "Parameters for get_items request are not correct: " + str ( e )
44- )
43+ f "Parameters for get_items request are not correct: { exc } "
44+ ) from exc
4545
4646
4747def get_items_response (amazon_api , request : GetItemsRequest ) -> List [Item ]:
4848 try :
49- response = amazon_api ._api .get_items (request )
50- except ApiException as e :
51- _manage_response_exceptions (e )
49+ response = amazon_api .api .get_items (request )
50+ except ApiException as exc :
51+ _manage_response_exceptions (exc )
5252
5353 if response .items_result is None :
5454 raise ItemsNotFoundException ("No items have been found" )
@@ -63,19 +63,19 @@ def get_search_items_request(amazon_api, **kwargs) -> SearchItemsRequest:
6363 partner_type = PartnerType .ASSOCIATES ,
6464 marketplace = amazon_api .marketplace ,
6565 partner_tag = amazon_api .tag ,
66- ** kwargs
66+ ** kwargs ,
6767 )
68- except TypeError as e :
68+ except TypeError as exc :
6969 raise MalformedRequestException (
70- "Parameters for search_items request are not correct: " + str ( e )
71- )
70+ f "Parameters for search_items request are not correct: { exc } "
71+ ) from exc
7272
7373
7474def get_search_items_response (amazon_api , request : SearchItemsRequest ) -> SearchResult :
7575 try :
76- response = amazon_api ._api .search_items (request )
77- except ApiException as e :
78- _manage_response_exceptions (e )
76+ response = amazon_api .api .search_items (request )
77+ except ApiException as exc :
78+ _manage_response_exceptions (exc )
7979
8080 if response .search_result is None :
8181 raise ItemsNotFoundException ("No items have been found" )
@@ -90,21 +90,21 @@ def get_variations_request(amazon_api, **kwargs) -> GetVariationsRequest:
9090 partner_type = PartnerType .ASSOCIATES ,
9191 marketplace = amazon_api .marketplace ,
9292 partner_tag = amazon_api .tag ,
93- ** kwargs
93+ ** kwargs ,
9494 )
95- except TypeError as e :
95+ except TypeError as exc :
9696 raise MalformedRequestException (
97- "Parameters for get_variations request are not correct: " + str ( e )
98- )
97+ f "Parameters for get_variations request are not correct: { exc } "
98+ ) from exc
9999
100100
101101def get_variations_response (
102102 amazon_api , request : GetVariationsRequest
103103) -> VariationsResult :
104104 try :
105- response = amazon_api ._api .get_variations (request )
106- except ApiException as e :
107- _manage_response_exceptions (e )
105+ response = amazon_api .api .get_variations (request )
106+ except ApiException as exc :
107+ _manage_response_exceptions (exc )
108108
109109 if response .variations_result is None :
110110 raise ItemsNotFoundException ("No variation items have been found" )
@@ -119,21 +119,21 @@ def get_browse_nodes_request(amazon_api, **kwargs) -> GetBrowseNodesRequest:
119119 partner_type = PartnerType .ASSOCIATES ,
120120 marketplace = amazon_api .marketplace ,
121121 partner_tag = amazon_api .tag ,
122- ** kwargs
122+ ** kwargs ,
123123 )
124- except TypeError as e :
124+ except TypeError as exc :
125125 raise MalformedRequestException (
126- "Parameters for get_browse_nodes request are not correct: " + str ( e )
127- )
126+ f "Parameters for get_browse_nodes request are not correct: { exc } "
127+ ) from exc
128128
129129
130130def get_browse_nodes_response (
131131 amazon_api , request : GetBrowseNodesRequest
132132) -> List [BrowseNode ]:
133133 try :
134- response = amazon_api ._api .get_browse_nodes (request )
135- except ApiException as e :
136- _manage_response_exceptions (e )
134+ response = amazon_api .api .get_browse_nodes (request )
135+ except ApiException as exc :
136+ _manage_response_exceptions (exc )
137137
138138 if response .browse_nodes_result is None :
139139 raise ItemsNotFoundException ("No browse nodes have been found" )
@@ -157,16 +157,16 @@ def _manage_response_exceptions(error) -> None:
157157 " trying again"
158158 )
159159
160- elif "InvalidParameterValue" in error .body :
160+ if "InvalidParameterValue" in error .body :
161161 raise InvalidArgumentException (
162162 "The value provided in the request for atleast one parameter is"
163163 " invalid."
164164 )
165165
166- elif "InvalidPartnerTag" in error .body :
166+ if "InvalidPartnerTag" in error .body :
167167 raise InvalidArgumentException ("The partner tag is invalid or not present." )
168168
169- elif "InvalidAssociate" in error .body :
169+ if "InvalidAssociate" in error .body :
170170 raise AssociateValidationException (
171171 "Used credentials are not valid for the selected country."
172172 )
0 commit comments