Skip to content

Commit ded4d50

Browse files
committed
All pylint errors fixed
1 parent 9f82e85 commit ded4d50

6 files changed

Lines changed: 37 additions & 51 deletions

File tree

amazon_paapi/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(
5252
except KeyError as error:
5353
raise InvalidArgumentException("Country code is not correct") from error
5454

55-
self._api = DefaultApi(key, secret, self._host, self.region)
55+
self.api = DefaultApi(key, secret, self._host, self.region)
5656

5757
def get_items(
5858
self,

amazon_paapi/errors/exceptions.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,36 @@ def __init__(self, reason: str):
99
self.reason = reason
1010

1111
def __str__(self) -> str:
12-
return "%s" % self.reason
12+
return self.reason
1313

1414

1515
class InvalidArgumentException(AmazonException):
1616
"""Raised when arguments are not correct."""
1717

18-
pass
19-
2018

2119
class AsinNotFoundException(AmazonException):
2220
"""Raised if the ASIN for an item is not found."""
2321

24-
pass
25-
2622

2723
class ApiRequestException(AmazonException):
2824
"""Raised if the request to Amazon API fails"""
2925

30-
pass
31-
3226

3327
class MalformedRequestException(AmazonException):
3428
"""Raised if the request for Amazon API is not correctly formed"""
3529

36-
pass
37-
3830

3931
class ItemsNotFoundException(AmazonException):
4032
"""Raised if no items are found"""
4133

42-
pass
43-
4434

4535
class TooManyRequestsException(AmazonException):
4636
"""Raised when requests limit is reached"""
4737

48-
pass
49-
5038

5139
class InvalidPartnerTagException(AmazonException):
5240
"""Raised if the partner tag is not present or invalid"""
5341

54-
pass
55-
5642

5743
class AssociateValidationException(AmazonException):
5844
"""Raised when credentials are not valid for the selected country"""
59-
60-
pass

amazon_paapi/helpers/requests.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4747
def 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

7474
def 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

101101
def 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

130130
def 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
)

examples/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from amazon_paapi import AmazonApi
44

5+
# pylint: disable=no-member
56
amazon = AmazonApi(
67
secrets.KEY, secrets.SECRET, secrets.TAG, secrets.COUNTRY, throttling=2
78
)

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ skip_glob = "*/sdk/*"
88

99
[tool.pylint]
1010
[tool.pylint.master]
11-
ignore-paths = ".*/sdk"
11+
ignore = ["test.py"]
12+
ignore-paths = [".*/sdk", ".*/docs"]
1213
[tool.pylint.message_control]
1314
disable = [
1415
"too-many-instance-attributes",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import setuptools
22

3-
with open("README.md", "r") as fh:
3+
with open("README.md", "r", encoding="utf8") as fh:
44
long_description = fh.read()
55

66
setuptools.setup(

0 commit comments

Comments
 (0)