Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#147)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)
- [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](codespell-project/codespell@v2.2.5...v2.2.6)

* exaust --> exhaust

* update pre-commit

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alex Kaszynski <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and akaszynski authored Oct 27, 2023
1 parent 1ba7889 commit 18f377f
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 69 deletions.
24 changes: 20 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.10.1
hooks:
- id: black
exclude: "^({{cookiecutter.project_slug}}/)"
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
files: '\.py$'
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
Expand All @@ -17,9 +21,8 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
exclude: "^({{cookiecutter.project_slug}}/)"
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
args: [-S ./docs/\*]
Expand All @@ -29,3 +32,16 @@ repos:
- id: pydocstyle
additional_dependencies: [toml]
exclude: "tests/"
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
args: [--py38-plus, --keep-runtime-typing]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: no-commit-to-branch
args: [--branch, main]
- id: requirements-txt-fixer
139 changes: 81 additions & 58 deletions keepa/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,28 +367,28 @@ class Keepa:
Create the api object.
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
Request data from two ASINs.
>>> products = api.query(['0439064872', '1426208081'])
>>> products = api.query(["0439064872", "1426208081"])
Print item details.
>>> print('Item 1')
>>> print('\t ASIN: {:s}'.format(products[0]['asin']))
>>> print('\t Title: {:s}'.format(products[0]['title']))
>>> print("Item 1")
>>> print("\t ASIN: {:s}".format(products[0]["asin"]))
>>> print("\t Title: {:s}".format(products[0]["title"]))
Item 1
ASIN: 0439064872
Title: Harry Potter and the Chamber of Secrets (2)
Print item price.
>>> usedprice = products[0]['data']['USED']
>>> usedtimes = products[0]['data']['USED_time']
>>> print('\t Used price: ${:.2f}'.format(usedprice[-1]))
>>> print('\t as of: {:s}'.format(str(usedtimes[-1])))
>>> usedprice = products[0]["data"]["USED"]
>>> usedtimes = products[0]["data"]["USED_time"]
>>> print("\t Used price: ${:.2f}".format(usedprice[-1]))
>>> print("\t as of: {:s}".format(str(usedtimes[-1])))
Used price: $0.52
as of: 2023-01-03 04:46:00
Expand Down Expand Up @@ -421,7 +421,7 @@ def time_to_refill(self) -> float:
should be 0.0 seconds.
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> api.time_to_refill
0.0
Expand Down Expand Up @@ -742,10 +742,10 @@ def query(
keepa interface.
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> response = api.query('B0088PUEPK')
>>> response[0]['title']
>>> response = api.query("B0088PUEPK")
>>> response[0]["title"]
'Western Digital 1TB WD Blue PC Internal Hard Drive HDD - 7200 RPM,
SATA 6 Gb/s, 64 MB Cache, 3.5" - WD10EZEX'
Expand All @@ -755,11 +755,12 @@ def query(
>>> import asyncio
>>> import keepa
>>> async def main():
... key = '<REAL_KEEPA_KEY>'
... key = "<REAL_KEEPA_KEY>"
... api = await keepa.AsyncKeepa().create(key)
... return await api.query('B0088PUEPK')
... return await api.query("B0088PUEPK")
...
>>> response = asyncio.run(main())
>>> response[0]['title']
>>> response[0]["title"]
'Western Digital 1TB WD Blue PC Internal Hard Drive HDD - 7200 RPM,
SATA 6 Gb/s, 64 MB Cache, 3.5" - WD10EZEX'
Expand Down Expand Up @@ -1026,7 +1027,7 @@ def best_sellers_query(self, category, rank_avg_range=0, domain="US", wait=True)
Query for the best sellers among the ``"movies"`` category.
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> categories = api.search_for_categories("movies")
>>> category = list(categories.items())[0][0]
Expand All @@ -1046,11 +1047,12 @@ def best_sellers_query(self, category, rank_avg_range=0, domain="US", wait=True)
>>> import asyncio
>>> import keepa
>>> async def main():
... key = '<REAL_KEEPA_KEY>'
... key = "<REAL_KEEPA_KEY>"
... api = await keepa.AsyncKeepa().create(key)
... categories = await api.search_for_categories("movies")
... category = list(categories.items())[0][0]
... return await api.best_sellers_query(category)
...
>>> asins = asyncio.run(main())
>>> asins
['B0BF3P5XZS',
Expand Down Expand Up @@ -1105,11 +1107,12 @@ def search_for_categories(self, searchterm, domain="US", wait=True) -> list:
Print all categories from science.
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> categories = api.search_for_categories('science')
>>> categories = api.search_for_categories("science")
>>> for cat_id in categories:
... print(cat_id, categories[cat_id]['name'])
... print(cat_id, categories[cat_id]["name"])
...
9091159011 Behavioral Sciences
8407535011 Fantasy, Horror & Science Fiction
8407519011 Sciences & Technology
Expand Down Expand Up @@ -1169,21 +1172,32 @@ def category_lookup(
Use 0 to return all root categories.
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> categories = api.category_lookup(0)
Print all root categories
>>> for cat_id in categories:
>>> print(cat_id, categories[cat_id]['name'])
133140011 Kindle Store
9013971011 Video Shorts
2350149011 Apps & Games
165796011 Baby Products
163856011 Digital Music
13727921011 Alexa Skills
...
Output the first category.
>>> list(categories.values())[0]
{'domainId': 1,
'catId': 133140011,
'name': 'Kindle Store',
'children': [133141011,
133143011,
6766606011,
7529231011,
118656435011,
2268072011,
119757513011,
358606011,
3000677011,
1293747011],
'parent': 0,
'highestRank': 6984155,
'productCount': 6417325,
'contextFreeName': 'Kindle Store',
'lowestRank': 1,
'matched': True}
"""
if domain not in DCODES:
Expand Down Expand Up @@ -1278,10 +1292,10 @@ def seller_query(
Return the information from seller ``'A2L77EE7U53NWQ'``.
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> seller_info = api.seller_query('A2L77EE7U53NWQ', 'US')
>>> seller_info['A2L77EE7U53NWQ']['sellerName']
>>> seller_info = api.seller_query("A2L77EE7U53NWQ", "US")
>>> seller_info["A2L77EE7U53NWQ"]["sellerName"]
'Amazon Warehouse'
Notes
Expand Down Expand Up @@ -2351,11 +2365,12 @@ def product_finder(self, product_parms, domain="US", wait=True) -> list:
``keepa.Keepa`` class. Sort by current sales
>>> import keepa
>>> api = keepa.Keepa('<ENTER_ACTUAL_KEY_HERE>')
>>> api = keepa.Keepa("<ENTER_ACTUAL_KEY_HERE>")
>>> product_parms = {
... 'author': 'jim butcher',
... 'sort': ``["current_SALES", "asc"]``,
}
... "author": "jim butcher",
... "sort": ["current_SALES", "asc"],
... }
>>> asins = api.product_finder(product_parms)
>>> asins
['B000HRMAR2',
Expand All @@ -2371,11 +2386,12 @@ def product_finder(self, product_parms, domain="US", wait=True) -> list:
>>> import asyncio
>>> import keepa
>>> product_parms = {'author': 'jim butcher'}
>>> product_parms = {"author": "jim butcher"}
>>> async def main():
... key = '<REAL_KEEPA_KEY>'
... key = "<REAL_KEEPA_KEY>"
... api = await keepa.AsyncKeepa().create(key)
... return await api.product_finder(product_parms)
...
>>> asins = asyncio.run(main())
>>> asins
['B000HRMAR2',
Expand Down Expand Up @@ -2470,17 +2486,19 @@ def deals(self, deal_parms, domain="US", wait=True) -> dict:
``keepa.Keepa`` class
>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> deal_parms = {"page": 0,
... "domainId": 1,
... "excludeCategories": [1064954, 11091801],
... "includeCategories": [16310101]}
>>> deal_parms = {
... "page": 0,
... "domainId": 1,
... "excludeCategories": [1064954, 11091801],
... "includeCategories": [16310101],
... }
>>> deals = api.deals(deal_parms)
Get the title of the first deal.
>>> deals['dr'][0]['title']
>>> deals["dr"][0]["title"]
'Orange Cream Rooibos, Tea Bags - Vanilla, Orange | Caffeine-Free,
Antioxidant-rich, Hot & Iced | The Spice Hut, First Sip Of Tea'
Expand All @@ -2489,15 +2507,18 @@ def deals(self, deal_parms, domain="US", wait=True) -> dict:
>>> import asyncio
>>> import keepa
>>> deal_parms = {"page": 0,
... "domainId": 1,
... "excludeCategories": [1064954, 11091801],
... "includeCategories": [16310101]}
>>> deal_parms = {
... "page": 0,
... "domainId": 1,
... "excludeCategories": [1064954, 11091801],
... "includeCategories": [16310101],
... }
>>> async def main():
... key = '<REAL_KEEPA_KEY>'
... key = "<REAL_KEEPA_KEY>"
... api = await keepa.AsyncKeepa().create(key)
... categories = await api.search_for_categories("movies")
... return await api.deals(deal_parms)
...
>>> asins = asyncio.run(main())
>>> asins
['B0BF3P5XZS',
Expand Down Expand Up @@ -2599,11 +2620,12 @@ class AsyncKeepa:
>>> import asyncio
>>> import keepa
>>> product_parms = {'author': 'jim butcher'}
>>> product_parms = {"author": "jim butcher"}
>>> async def main():
... key = '<REAL_KEEPA_KEY>'
... key = "<REAL_KEEPA_KEY>"
... api = await keepa.AsyncKeepa().create(key)
... return await api.product_finder(product_parms)
...
>>> asins = asyncio.run(main())
>>> asins
['B000HRMAR2',
Expand All @@ -2620,11 +2642,12 @@ class AsyncKeepa:
>>> import asyncio
>>> import keepa
>>> async def main():
... key = '<REAL_KEEPA_KEY>'
... key = "<REAL_KEEPA_KEY>"
... api = await keepa.AsyncKeepa().create(key)
... return await api.query('B0088PUEPK')
... return await api.query("B0088PUEPK")
...
>>> response = asyncio.run(main())
>>> response[0]['title']
>>> response[0]["title"]
'Western Digital 1TB WD Blue PC Internal Hard Drive HDD - 7200 RPM,
SATA 6 Gb/s, 64 MB Cache, 3.5" - WD10EZEX'
Expand Down
2 changes: 1 addition & 1 deletion requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx==6.1.2
pydata-sphinx-theme==0.12.0
sphinx==6.1.2
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
matplotlib==3.7.1
pandas
pytest==7.3.1
pytest-asyncio==0.21.0
pytest-cov==4.0.0
pytest==7.3.1
2 changes: 1 addition & 1 deletion tests/test_async_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def test_product_finder_query(api):
# api = keepa.Keepa(WEAKTESTINGKEY)
# keepa.interface.REQLIM = 20

# # exaust tokens
# # exhaust tokens
# while api.tokens_left > 0:
# api.query(PRODUCT_ASINS[:5])

Expand Down
6 changes: 2 additions & 4 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_product_finder_query(api):
# api = keepa.Keepa(WEAKTESTINGKEY)
# keepa.interface.REQLIM = 20

# # exaust tokens
# # exhaust tokens
# while api.tokens_left > 0:
# api.query(PRODUCT_ASINS[:5])

Expand Down Expand Up @@ -261,9 +261,7 @@ def test_productquery_days(api, max_days: int = 5):

def convert(minutes):
"""Convert keepaminutes to time."""
times = set(
keepa_minutes_to_time(keepa_minute).date() for keepa_minute in minutes
)
times = {keepa_minutes_to_time(keepa_minute).date() for keepa_minute in minutes}
return list(times)

# Converting each field's list of keepa minutes into flat list of unique days.
Expand Down

0 comments on commit 18f377f

Please sign in to comment.