Skip to content

Commit f95e726

Browse files
committed
Fixed flake8 errors
1 parent 124d8fb commit f95e726

3 files changed

Lines changed: 107 additions & 71 deletions

File tree

amazon_paapi/api.py

Lines changed: 80 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class AmazonApi:
2222
secret (``str``): Your API secret.
2323
tag (``str``): Your affiliate tracking id, used to create the affiliate link.
2424
country (``models.Country``): Country code for your affiliate account.
25-
throttling (``float``, optional): Wait time in seconds between API calls. Use it to avoid
26-
reaching Amazon limits. Defaults to 1 second.
25+
throttling (``float``, optional): Wait time in seconds between API calls. Use it
26+
to avoid reaching Amazon limits. Defaults to 1 second.
2727
2828
Raises:
2929
``InvalidArgumentException``
@@ -67,19 +67,21 @@ def get_items(
6767
"""Get items information from Amazon.
6868
6969
Args:
70-
items (``str`` | ``list[str]``): One or more items, using ASIN or product URL. Items
71-
in string format should be separated by commas.
72-
condition (``models.Condition``, optional): Filters offers by condition type.
73-
Defaults to Any.
74-
merchant (``models.Merchant``, optional): Filters search results to return items having
75-
at least one offer sold by target merchant. Defaults to All.
76-
currency_of_preference (``str``, optional): Currency of preference in which the prices
77-
information should be returned. Expected currency code format is ISO 4217.
78-
languages_of_preference (``list[str]``, optional): Languages in order of preference in
79-
which the item information should be returned.
80-
include_unavailable (``bool``, optional): The returned list includes not available
81-
items. Not available items have the ASIN and item_info equals None. Defaults to False.
82-
kwargs (``dict``, optional): Any other arguments to be passed to the Amazon API.
70+
items (``str`` | ``list[str]``): One or more items, using ASIN or product
71+
URL. Items in string format should be separated by commas.
72+
condition (``models.Condition``, optional): Filters offers by condition
73+
type. Defaults to Any.
74+
merchant (``models.Merchant``, optional): Filters search results to return
75+
items having at least an offer sold by target merchant. Defaults to All.
76+
currency_of_preference (``str``, optional): Currency of preference in which
77+
the prices information should be returned. Expected currency code format
78+
is ISO 4217.
79+
languages_of_preference (``list[str]``, optional): Languages in order of
80+
preference in which the item information should be returned.
81+
include_unavailable (``bool``, optional): The returned list includes not
82+
available items. Not available items have the ASIN and item_info equals
83+
None. Defaults to False.
84+
kwargs (``dict``, optional): Other arguments to be passed to the Amazon API.
8385
8486
Returns:
8587
``list[models.Item]``: A list of items with Amazon information.
@@ -136,47 +138,54 @@ def search_items(
136138
sort_by: models.SortBy = None,
137139
**kwargs
138140
) -> models.SearchResult:
139-
"""Searches for items on Amazon based on a search query. At least one of the following
140-
parameters should be specified: ``keywords``, ``actor``, ``artist``, ``author``,
141-
``brand``, ``title``, ``browse_node_id`` or ``search_index``.
141+
"""Searches for items on Amazon based on a search query. At least one of the
142+
following parameters should be specified: ``keywords``, ``actor``, ``artist``,
143+
``author``, ``brand``, ``title``, ``browse_node_id`` or ``search_index``.
142144
143145
Args:
144-
item_count (``int``, optional): Number of items returned. Should be between 1 and 10.
145-
Defaults to 10.
146-
item_page (``int``, optional): The specific page of items to be returned from the available
147-
results. Should be between 1 and 10. Defaults to 1.
146+
item_count (``int``, optional): Number of items returned. Should be between
147+
1 and 10. Defaults to 10.
148+
item_page (``int``, optional): The specific page of items to be returned
149+
from the available results. Should be between 1 and 10. Defaults to 1.
148150
actor (``str``, optional): Actor name associated with the item.
149151
artist (``str``, optional): Artist name associated with the item.
150152
author (``str``, optional): Author name associated with the item.
151153
brand (``str``, optional): Brand name associated with the item.
152154
keywords (``str``, optional): A word or phrase that describes an item.
153155
title (``str``, optional): Title associated with the item.
154-
availability (``models.Availability``, optional): Filters available items on Amazon.
155-
Defaults to Available.
156-
browse_node_id (``str``, optional): A unique ID assigned by Amazon that identifies a product
157-
category or subcategory.
158-
condition (``models.Condition``, optional): Filters offers by condition type. Defaults to Any.
159-
currency_of_preference (``str``, optional): Currency of preference in which the prices
160-
information should be returned. Expected currency code format is ISO 4217.
161-
delivery_flags (``list[str]``): Filters items which satisfy a certain delivery program.
162-
languages_of_preference (``list[str]``, optional): Languages in order of preference in
163-
which the item information should be returned.
164-
merchant (``models.Merchant``, optional): Filters search results to return items having
165-
at least one offer sold by target merchant. Defaults to All.
166-
max_price (``int``, optional): Filters search results to items with at least one offer price
167-
below the specified value. Prices appear in lowest currency denomination.
168-
For example, $31.41 should be passed as 3141 or 28.00€ should be 2800.
169-
min_price (``int``, optional): Filters search results to items with at least one offer price
170-
above the specified value. Prices appear in lowest currency denomination.
171-
For example, $31.41 should be passed as 3141 or 28.00€ should be 2800.
172-
min_saving_percent (``int``, optional): Filters search results to items with at least one
173-
offer having saving percentage above the specified value. Value should be
174-
positive integer less than 100.
175-
min_reviews_rating (``int``, optional): Filters search results to items with customer review
176-
ratings above specified value. Value should be positive integer less than 5.
177-
search_index (``str``, optional): Indicates the product category to search. Defaults to All.
156+
availability (``models.Availability``, optional): Filters available items on
157+
Amazon. Defaults to Available.
158+
browse_node_id (``str``, optional): A unique ID assigned by Amazon that
159+
identifies a product category or subcategory.
160+
condition (``models.Condition``, optional): Filters offers by condition
161+
type. Defaults to Any.
162+
currency_of_preference (``str``, optional): Currency of preference in which
163+
the prices information should be returned. Expected currency code format
164+
is ISO 4217.
165+
delivery_flags (``list[str]``): Filters items which satisfy a certain
166+
delivery program.
167+
languages_of_preference (``list[str]``, optional): Languages in order of
168+
preference in which the item information should be returned.
169+
merchant (``models.Merchant``, optional): Filters search results to return
170+
items having at least an offer sold by target merchant. Defaults to All.
171+
max_price (``int``, optional): Filters search results to items with at least
172+
one offer price below the specified value. Prices appear in lowest
173+
currency denomination. For example, $31.41 should be passed as 3141 or
174+
28.00€ should be 2800.
175+
min_price (``int``, optional): Filters search results to items with at least
176+
one offer price above the specified value. Prices appear in lowest
177+
currency denomination. For example, $31.41 should be passed as 3141 or
178+
28.00€ should be 2800.
179+
min_saving_percent (``int``, optional): Filters search results to items with
180+
at least one offer having saving percentage above the specified value.
181+
Value should be positive integer less than 100.
182+
min_reviews_rating (``int``, optional): Filters search results to items with
183+
customer review ratings above specified value. Value should be positive
184+
integer less than 5.
185+
search_index (``str``, optional): Indicates the product category to search.
186+
Defaults to All.
178187
sort_by (``models.SortBy``, optional): The way in which items are sorted.
179-
kwargs (``dict``, optional): Any other arguments to be passed to the Amazon API.
188+
kwargs (``dict``, optional): Other arguments to be passed to the Amazon API.
180189
181190
Returns:
182191
``models.SearchResult``: The search result containing the list of items.
@@ -235,21 +244,24 @@ def get_variations(
235244
236245
Args:
237246
asin (``str``): One item, using ASIN or product URL.
238-
variation_count (``int``, optional): Number of items returned. Should be between 1 and 10.
239-
Defaults to 10.
240-
variation_page (``int``, optional): The specific page of items to be returned from the available
241-
results. Should be between 1 and 10. Defaults to 1.
242-
condition (``models.Condition``, optional): Filters offers by condition type. Defaults to Any.
243-
currency_of_preference (``str``, optional): Currency of preference in which the prices
244-
information should be returned. Expected currency code format is ISO 4217.
245-
languages_of_preference (``list[str]``, optional): Languages in order of preference in
246-
which the item information should be returned.
247-
merchant (``models.Merchant``, optional): Filters search results to return items having
248-
at least one offer sold by target merchant. Defaults to All.
249-
kwargs (``dict``, optional): Any other arguments to be passed to the Amazon API.
247+
variation_count (``int``, optional): Number of items returned. Should be
248+
between 1 and 10. Defaults to 10.
249+
variation_page (``int``, optional): The specific page of items to be
250+
returned from the available results. Should be between 1 and 10.
251+
Defaults to 1.
252+
condition (``models.Condition``, optional): Filters offers by condition
253+
type. Defaults to Any.
254+
currency_of_preference (``str``, optional): Currency of preference in which
255+
the prices information should be returned. Expected currency code format
256+
is ISO 4217.
257+
languages_of_preference (``list[str]``, optional): Languages in order of
258+
preference in which the item information should be returned.
259+
merchant (``models.Merchant``, optional): Filters search results to return
260+
items having at least an offer sold by target merchant. Defaults to All.
261+
kwargs (``dict``, optional): Other arguments to be passed to the Amazon API.
250262
251263
Returns:
252-
``models.VariationsResult``: The variations result containing the list of items.
264+
``models.VariationsResult``: Variations result containing the items list.
253265
254266
Raises:
255267
``InvalidArgumentException``
@@ -283,14 +295,16 @@ def get_browse_nodes(
283295
languages_of_preference: List[str] = None,
284296
**kwargs
285297
) -> List[models.BrowseNode]:
286-
"""Returns the specified browse node's information like name, children and ancestors.
298+
"""Returns the specified browse node's information like name, children and
299+
ancestors.
287300
288301
Args:
289-
browse_node_ids (``list[str]``): List of browse node ids. A browse node id is a unique
290-
ID assigned by Amazon that identifies a product category/sub-category.
291-
languages_of_preference (``list[str]``, optional): Languages in order of preference in
292-
which the item information should be returned.
293-
kwargs (``dict``, optional): Any other arguments to be passed to the Amazon API.
302+
browse_node_ids (``list[str]``): List of browse node ids. A browse node id
303+
is a unique ID assigned by Amazon that identifies a product
304+
category/sub-category.
305+
languages_of_preference (``list[str]``, optional): Languages in order of
306+
preference in which the item information should be returned.
307+
kwargs (``dict``, optional): Other arguments to be passed to the Amazon API.
294308
295309
Returns:
296310
``list[models.BrowseNode]``: A list of browse nodes.

amazon_paapi/errors/__init__.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
from .exceptions import *
1+
from .exceptions import (
2+
AmazonException,
3+
ApiRequestException,
4+
AsinNotFoundException,
5+
AssociateValidationException,
6+
InvalidArgumentException,
7+
InvalidPartnerTagException,
8+
ItemsNotFoundException,
9+
MalformedRequestException,
10+
TooManyRequestsException,
11+
)
12+
13+
__all__ = [
14+
"AmazonException",
15+
"ApiRequestException",
16+
"AsinNotFoundException",
17+
"AssociateValidationException",
18+
"InvalidArgumentException",
19+
"InvalidPartnerTagException",
20+
"ItemsNotFoundException",
21+
"MalformedRequestException",
22+
"TooManyRequestsException",
23+
]

amazon_paapi/helpers/requests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_items_response(amazon_api, request: GetItemsRequest) -> List[Item]:
5050
except ApiException as e:
5151
_manage_response_exceptions(e)
5252

53-
if response.items_result == None:
53+
if response.items_result is None:
5454
raise ItemsNotFoundException("No items have been found")
5555

5656
return response.items_result.items
@@ -77,7 +77,7 @@ def get_search_items_response(amazon_api, request: SearchItemsRequest) -> Search
7777
except ApiException as e:
7878
_manage_response_exceptions(e)
7979

80-
if response.search_result == None:
80+
if response.search_result is None:
8181
raise ItemsNotFoundException("No items have been found")
8282

8383
return response.search_result
@@ -106,7 +106,7 @@ def get_variations_response(
106106
except ApiException as e:
107107
_manage_response_exceptions(e)
108108

109-
if response.variations_result == None:
109+
if response.variations_result is None:
110110
raise ItemsNotFoundException("No variation items have been found")
111111

112112
return response.variations_result
@@ -135,7 +135,7 @@ def get_browse_nodes_response(
135135
except ApiException as e:
136136
_manage_response_exceptions(e)
137137

138-
if response.browse_nodes_result == None:
138+
if response.browse_nodes_result is None:
139139
raise ItemsNotFoundException("No browse nodes have been found")
140140

141141
return response.browse_nodes_result.browse_nodes

0 commit comments

Comments
 (0)