diff options
Diffstat (limited to 'requests_cache')
-rw-r--r-- | requests_cache/backends/base.py | 8 | ||||
-rw-r--r-- | requests_cache/backends/filesystem.py | 2 | ||||
-rw-r--r-- | requests_cache/backends/gridfs.py | 2 | ||||
-rw-r--r-- | requests_cache/backends/sqlite.py | 2 | ||||
-rw-r--r-- | requests_cache/models/raw_response.py | 2 | ||||
-rw-r--r-- | requests_cache/patcher.py | 1 |
6 files changed, 13 insertions, 4 deletions
diff --git a/requests_cache/backends/base.py b/requests_cache/backends/base.py index d64abc1..39df413 100644 --- a/requests_cache/backends/base.py +++ b/requests_cache/backends/base.py @@ -275,6 +275,7 @@ class BaseCache: warn( 'BaseCache.delete_url() is deprecated; please use .delete(urls=...) instead', DeprecationWarning, + stacklevel=2, ) self.delete(requests=[Request(method, url, **kwargs)]) @@ -282,6 +283,7 @@ class BaseCache: warn( 'BaseCache.delete_urls() is deprecated; please use .delete(urls=...) instead', DeprecationWarning, + stacklevel=2, ) self.delete(requests=[Request(method, url, **kwargs) for url in urls]) @@ -289,6 +291,7 @@ class BaseCache: warn( 'BaseCache.has_key() is deprecated; please use .contains() instead', DeprecationWarning, + stacklevel=2, ) return self.contains(key) @@ -296,6 +299,7 @@ class BaseCache: warn( 'BaseCache.has_url() is deprecated; please use .contains(url=...) instead', DeprecationWarning, + stacklevel=2, ) return self.contains(request=Request(method, url, **kwargs)) @@ -304,6 +308,7 @@ class BaseCache: 'BaseCache.keys() is deprecated; ' 'please use .filter() or BaseCache.responses.keys() instead', DeprecationWarning, + stacklevel=2, ) yield from self.redirects.keys() if not check_expiry: @@ -317,6 +322,7 @@ class BaseCache: 'BaseCache.response_count() is deprecated; ' 'please use .filter() or len(BaseCache.responses) instead', DeprecationWarning, + stacklevel=2, ) return len(list(self.filter(expired=not check_expiry))) @@ -325,6 +331,7 @@ class BaseCache: 'BaseCache.remove_expired_responses() is deprecated; ' 'please use .delete(expired=True) instead', DeprecationWarning, + stacklevel=2, ) if expire_after: self.reset_expiration(expire_after) @@ -335,6 +342,7 @@ class BaseCache: 'BaseCache.values() is deprecated; ' 'please use .filter() or BaseCache.responses.values() instead', DeprecationWarning, + stacklevel=2, ) yield from self.filter(expired=not check_expiry) diff --git a/requests_cache/backends/filesystem.py b/requests_cache/backends/filesystem.py index ccda6c8..9641668 100644 --- a/requests_cache/backends/filesystem.py +++ b/requests_cache/backends/filesystem.py @@ -94,7 +94,7 @@ class FileDict(BaseStorage): yield except (EOFError, IOError, OSError, PickleError) as e: if not ignore_errors: - raise KeyError(e) + raise KeyError from e def _path(self, key) -> Path: return self.cache_dir / f'{key}{self.extension}' diff --git a/requests_cache/backends/gridfs.py b/requests_cache/backends/gridfs.py index aadb7e5..ee2fd23 100644 --- a/requests_cache/backends/gridfs.py +++ b/requests_cache/backends/gridfs.py @@ -87,7 +87,7 @@ class GridFSDict(BaseStorage): return self.deserialize(key, result.read()) except CorruptGridFile as e: logger.warning(e, exc_info=True) - raise KeyError + raise KeyError from e def __setitem__(self, key, item): value = self.serialize(item) diff --git a/requests_cache/backends/sqlite.py b/requests_cache/backends/sqlite.py index 72b62da..2840e63 100644 --- a/requests_cache/backends/sqlite.py +++ b/requests_cache/backends/sqlite.py @@ -426,7 +426,7 @@ def get_cache_path(db_path: AnyPath, use_cache_dir: bool = False, use_temp: bool raise FileExistsError( f'Parent path exists and is not a directory: {db_path.parent}.' 'Please either delete the file or choose a different path.' - ) + ) from None return db_path diff --git a/requests_cache/models/raw_response.py b/requests_cache/models/raw_response.py index f95afab..ea51eb5 100644 --- a/requests_cache/models/raw_response.py +++ b/requests_cache/models/raw_response.py @@ -57,7 +57,7 @@ class CachedHTTPResponse(RichMixin, HTTPResponse): body = raw.read(decode_content=False) kwargs['body'] = body raw._fp = BytesIO(body) - response.content # This property reads, decodes, and stores response content + _ = response.content # This property reads, decodes, and stores response content # After reading, reset file pointer on original raw response raw._fp = BytesIO(body) diff --git a/requests_cache/patcher.py b/requests_cache/patcher.py index 406ee45..aa5af76 100644 --- a/requests_cache/patcher.py +++ b/requests_cache/patcher.py @@ -121,6 +121,7 @@ def remove_expired_responses(): warn( 'remove_expired_responses() is deprecated; please use delete() instead', DeprecationWarning, + stacklevel=2, ) delete(expired=True) |