Skip to content

Commit fd008e5

Browse files
Loosen dependency pins: cachetools, aiohttp, requests (#129)
* Loosen dependency pins: cachetools, aiohttp, requests * Refactor cache import to streamline usage of TTLCache * Fix missing await on resp.text() in async handlers * Fix async tests --------- Co-authored-by: Silvano Cerza <silvanocerza@gmail.com>
1 parent 40593d5 commit fd008e5

9 files changed

Lines changed: 15 additions & 17 deletions

ipinfo/cache/default.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
A default cache implementation that uses `cachetools` for an in-memory LRU cache.
33
"""
44

5-
import cachetools
6-
75
from .interface import CacheInterface
8-
6+
from cachetools import TTLCache
97

108
class DefaultCache(CacheInterface):
119
"""Default, in-memory cache."""
1210

1311
def __init__(self, **cache_options):
14-
self.cache = cachetools.TTLCache(**cache_options)
12+
self.cache = TTLCache(**cache_options)
1513

1614
def __contains__(self, key):
1715
return self.cache.__contains__(key)

ipinfo/handler_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async def getDetails(self, ip_address=None, timeout=None):
150150
if content_type == "application/json":
151151
error_response = await resp.json()
152152
else:
153-
error_response = {"error": resp.text()}
153+
error_response = {"error": await resp.text()}
154154
raise APIError(error_code, error_response)
155155
details = await resp.json()
156156

@@ -208,7 +208,7 @@ async def getResproxy(self, ip_address, timeout=None):
208208
if content_type == "application/json":
209209
error_response = await resp.json()
210210
else:
211-
error_response = {"error": resp.text()}
211+
error_response = {"error": await resp.text()}
212212
raise APIError(error_code, error_response)
213213
details = await resp.json()
214214

ipinfo/handler_core_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async def getDetails(self, ip_address=None, timeout=None):
153153
if content_type == "application/json":
154154
error_response = await resp.json()
155155
else:
156-
error_response = {"error": resp.text()}
156+
error_response = {"error": await resp.text()}
157157
raise APIError(error_code, error_response)
158158
details = await resp.json()
159159

ipinfo/handler_lite_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async def getDetails(self, ip_address=None, timeout=None):
141141
if content_type == "application/json":
142142
error_response = await resp.json()
143143
else:
144-
error_response = {"error": resp.text()}
144+
error_response = {"error": await resp.text()}
145145
raise APIError(error_code, error_response)
146146
details = await resp.json()
147147

ipinfo/handler_plus_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async def getDetails(self, ip_address=None, timeout=None):
153153
if content_type == "application/json":
154154
error_response = await resp.json()
155155
else:
156-
error_response = {"error": resp.text()}
156+
error_response = {"error": await resp.text()}
157157
raise APIError(error_code, error_response)
158158
details = await resp.json()
159159

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ authors = [
99
license = { text = "Apache License 2.0" }
1010
requires-python = ">=3.10"
1111
dependencies = [
12-
"requests>=2.18.4",
13-
"cachetools==4.2.0",
14-
"aiohttp>=3.12.14,<=4",
12+
"requests>=2.18.4,<3",
13+
"cachetools>=4.2,<8",
14+
"aiohttp>=3,<4",
1515
]
1616

1717
[project.urls]

tests/handler_async_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, text, status, headers):
2222
self.status = status
2323
self.headers = headers
2424

25-
def text(self):
25+
async def text(self):
2626
return self._text
2727

2828
async def json(self):

tests/handler_lite_async_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, text, status, headers):
1717
self.status = status
1818
self.headers = headers
1919

20-
def text(self):
20+
async def text(self):
2121
return self._text
2222

2323
async def json(self):

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)