summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2021-08-08 20:02:00 -0500
committerJordan Cook <jordan.cook@pioneer.com>2021-08-14 21:58:28 -0500
commitbc7ab17836d2afe03db198730f9c8a5aee922a44 (patch)
treee680923529e4f4a1e97643e62fd1bc9ee3bac778
parent707a054da49b3a5ccbac9e16bfb490f1ff65ccb6 (diff)
downloadrequests-cache-bc7ab17836d2afe03db198730f9c8a5aee922a44.tar.gz
Remove deprecated 'core' module and BaseCache.remove_old_entries()
-rw-r--r--.pre-commit-config.yaml4
-rw-r--r--HISTORY.md9
-rw-r--r--README.md2
-rw-r--r--requests_cache/backends/base.py6
-rw-r--r--requests_cache/core.py8
-rw-r--r--requests_cache/serializers/__init__.py10
-rw-r--r--tests/unit/test_serializers.py15
-rw-r--r--tests/unit/test_session.py11
8 files changed, 18 insertions, 47 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7990ae0..72576ef 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -35,5 +35,5 @@ repos:
- repo: https://github.com/yunojuno/pre-commit-xenon
rev: v0.1
hooks:
- - id: xenon
- args: [--max-average=A, --max-modules=B, --max-absolute=C]
+ - id: xenon
+ args: [--max-average=A, --max-modules=B, --max-absolute=C]
diff --git a/HISTORY.md b/HISTORY.md
index ba6f447..d81d817 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,5 +1,12 @@
# History
+### 0.8.0 (TBD)
+* Use `cattrs` for serialization by default
+* Drop support for python 3.6
+ * Note: Any bugfixes for 0.8.x that also apply to 0.7.x will be backported
+* Remove deprecated `core` module
+* Remove deprecated `BaseCache.remove_old_entries()` method
+
### 0.7.4 (2021-08-16)
* Fix an issue with httpdate strings from `Expires` headers not getting converted to UTC
* Fix a packaging issue with extra files added to top-level wheel directory
@@ -161,6 +168,8 @@ next time they are requested. They can also be manually converted or removed, if
### General
* Drop support for python <= 3.5
+* Deprecate `core` module; all imports should be made from top-level package instead
+ * e.g.: `from requests_cache import CachedSession`
* Add `CacheMixin` class to make the features of `CachedSession` usable as a mixin class,
for [compatibility with other requests-based libraries](https://requests-cache.readthedocs.io/en/stable/advanced_usage.html#library-compatibility).
* Add `HEAD` to default `allowable_methods`
diff --git a/README.md b/README.md
index a6c5c12..1d663af 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
[![Code Shelter](https://www.codeshelter.co/static/badges/badge-flat.svg)](https://www.codeshelter.co/)
## Summary
-**requests-cache** is a transparent, persistent HTTP cache for the python [requests](http://python-requests.org)
+**requests-cache** is a transparent, persistent cache for the python [requests](http://python-requests.org)
library. It's a convenient tool to use with web scraping, consuming REST APIs, slow or rate-limited
sites, or any other scenario in which you're making lots of requests that are expensive and/or
likely to be sent more than once.
diff --git a/requests_cache/backends/base.py b/requests_cache/backends/base.py
index 2ed9503..7ee7ccd 100644
--- a/requests_cache/backends/base.py
+++ b/requests_cache/backends/base.py
@@ -1,5 +1,4 @@
import pickle
-import warnings
from abc import ABC
from collections import UserDict
from collections.abc import MutableMapping
@@ -152,11 +151,6 @@ class BaseCache:
for key, response in keys_to_update.items():
self.responses[key] = response
- def remove_old_entries(self, *args, **kwargs):
- msg = 'BaseCache.remove_old_entries() is deprecated; please use CachedSession.remove_expired_responses()'
- warnings.warn(DeprecationWarning(msg))
- self.remove_expired_responses(*args, **kwargs)
-
def create_key(self, request: AnyRequest, **kwargs) -> str:
"""Create a normalized cache key from a request object"""
return create_key(request, self.ignored_parameters, self.include_get_headers, **kwargs)
diff --git a/requests_cache/core.py b/requests_cache/core.py
deleted file mode 100644
index 7d3999e..0000000
--- a/requests_cache/core.py
+++ /dev/null
@@ -1,8 +0,0 @@
-"""Placeholder module for backwards-compatibility"""
-import warnings
-
-from .patcher import * # noqa: F401, F403
-from .session import * # noqa: F401, F403
-
-msg = 'The module `requests_cache.core` is deprecated; please import from `requests_cache`.'
-warnings.warn(DeprecationWarning(msg))
diff --git a/requests_cache/serializers/__init__.py b/requests_cache/serializers/__init__.py
index e3fa6de..8d6c272 100644
--- a/requests_cache/serializers/__init__.py
+++ b/requests_cache/serializers/__init__.py
@@ -33,14 +33,6 @@ SERIALIZERS = {
def init_serializer(serializer=None, **kwargs):
"""Initialize a serializer from a name, class, or instance"""
serializer = serializer or 'pickle'
- # Backwards=compatibility with 0.6; will be removed in 0.8
- if serializer == 'safe_pickle' or (serializer == 'pickle' and 'secret_key' in kwargs):
- serializer = safe_pickle_serializer(**kwargs)
- msg = (
- 'Please initialize with safe_pickle_serializer(secret_key) instead. '
- 'This usage is deprecated and will be removed in a future version.'
- )
- warn(DeprecationWarning(msg))
- elif isinstance(serializer, str):
+ if isinstance(serializer, str):
serializer = SERIALIZERS[serializer]
return serializer
diff --git a/tests/unit/test_serializers.py b/tests/unit/test_serializers.py
index dbaf967..a1f5e37 100644
--- a/tests/unit/test_serializers.py
+++ b/tests/unit/test_serializers.py
@@ -10,7 +10,7 @@ import pytest
from itsdangerous import Signer
from itsdangerous.exc import BadSignature
-from requests_cache import CachedResponse, CachedSession, pickle_serializer
+from requests_cache import CachedResponse, CachedSession, safe_pickle_serializer
def test_stdlib_json():
@@ -55,15 +55,9 @@ def test_optional_dependencies():
reload(requests_cache.serializers.preconf)
-# TODO: This usage is deprecated. Keep this test for backwards-compatibility until removed in a future release.
-@pytest.mark.skipif(sys.version_info < (3, 7), reason='Requires python 3.7+')
def test_cache_signing(tempfile_path):
- session = CachedSession(tempfile_path)
- assert session.cache.responses.serializer == pickle_serializer
-
- # With a secret key, itsdangerous should be used
- secret_key = str(uuid4())
- session = CachedSession(tempfile_path, secret_key=secret_key)
+ serializer = safe_pickle_serializer(secret_key=str(uuid4()))
+ session = CachedSession(tempfile_path, serializer=serializer)
assert isinstance(session.cache.responses.serializer.steps[-1].obj, Signer)
# Simple serialize/deserialize round trip
@@ -72,6 +66,7 @@ def test_cache_signing(tempfile_path):
assert session.cache.responses['key'] == response
# Without the same signing key, the item shouldn't be considered safe to deserialize
- session = CachedSession(tempfile_path, secret_key='a different key')
+ serializer = safe_pickle_serializer(secret_key='a different key')
+ session = CachedSession(tempfile_path, serializer=serializer)
with pytest.raises(BadSignature):
session.cache.responses['key']
diff --git a/tests/unit/test_session.py b/tests/unit/test_session.py
index d5cc395..3c5e8c5 100644
--- a/tests/unit/test_session.py
+++ b/tests/unit/test_session.py
@@ -61,17 +61,6 @@ def test_init_backend_class():
assert isinstance(session.cache, MyCache)
-def test_import_compat():
- """Just make sure that we can still import from requests_cache.core"""
- with pytest.deprecated_call():
- from requests_cache.core import CachedSession, install_cache # noqa: F401
-
-
-def test_method_compat(mock_session):
- with pytest.deprecated_call():
- mock_session.cache.remove_old_entries()
-
-
@pytest.mark.parametrize('method', ALL_METHODS)
@pytest.mark.parametrize('field', ['params', 'data', 'json'])
def test_all_methods(field, method, mock_session):