diff options
-rw-r--r-- | .github/workflows/build.yml | 2 | ||||
-rw-r--r-- | docs/user_guide.md | 4 | ||||
-rw-r--r-- | noxfile.py | 2 | ||||
-rw-r--r-- | poetry.lock | 88 | ||||
-rw-r--r-- | pyproject.toml | 29 | ||||
-rw-r--r-- | requests_cache/__init__.py | 2 | ||||
-rwxr-xr-x | requests_cache/models/response.py | 6 | ||||
-rw-r--r-- | requests_cache/serializers/__init__.py | 32 | ||||
-rw-r--r-- | requests_cache/serializers/cattrs.py | 2 | ||||
-rw-r--r-- | requests_cache/serializers/preconf.py | 2 | ||||
-rw-r--r-- | tests/integration/test_compat.py | 4 | ||||
-rw-r--r-- | tests/unit/test_serializers.py | 4 |
12 files changed, 55 insertions, 122 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3bc5c1..91a7d00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-18.04 strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.2] + python-version: [3.7, 3.8, 3.9, 3.10.0-beta.4] fail-fast: false services: nginx: diff --git a/docs/user_guide.md b/docs/user_guide.md index 8b74f14..9fda803 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -14,7 +14,7 @@ conda install -c conda-forge requests-cache ``` ### Requirements -- Requires python 3.6+. +- Requires python 3.7+. - You may need additional dependencies depending on which backend you want to use. To install with extra dependencies for all supported {ref}`user_guide:cache backends`: ``` @@ -318,7 +318,7 @@ revalidate the cache with the new expiration time: By default, responses are serialized using {py:mod}`pickle`. Some other options are also available: :::{note} -These features require python 3.7+ and additional dependencies +These features require additional dependencies ::: ### JSON Serializer @@ -23,7 +23,7 @@ COVERAGE_ARGS = '--cov --cov-report=term --cov-report=html' # Generate HTML + s XDIST_ARGS = '--numprocesses=auto --dist=loadfile' # Run tests in parallel, grouped by test module -@session(python=['3.6', '3.7', '3.8', '3.9', '3.10']) +@session(python=['3.7', '3.8', '3.9', '3.10']) def test(session): """Run tests for a specific python version""" test_paths = session.posargs or [UNIT_TESTS] diff --git a/poetry.lock b/poetry.lock index 4e70ec5..5367c31 100644 --- a/poetry.lock +++ b/poetry.lock @@ -15,7 +15,7 @@ optional = false python-versions = "*" [package.dependencies] -importlib-metadata = {version = ">=0.23,<5", markers = "python_version == \"3.6\" or python_version == \"3.7\""} +importlib-metadata = {version = ">=0.23,<5", markers = "python_version == \"3.7\""} [package.extras] test = ["coverage", "flake8", "pexpect", "wheel"] @@ -85,20 +85,20 @@ lxml = ["lxml"] [[package]] name = "boto3" -version = "1.15.18" +version = "1.16.63" description = "The AWS SDK for Python" category = "main" optional = true python-versions = "*" [package.dependencies] -botocore = ">=1.18.18,<1.19.0" +botocore = ">=1.19.63,<1.20.0" jmespath = ">=0.7.1,<1.0.0" s3transfer = ">=0.3.0,<0.4.0" [[package]] name = "botocore" -version = "1.18.18" +version = "1.19.63" description = "Low-level, data-driven core of boto 3." category = "main" optional = true @@ -107,7 +107,7 @@ python-versions = "*" [package.dependencies] jmespath = ">=0.7.1,<1.0.0" python-dateutil = ">=2.1,<3.0.0" -urllib3 = {version = ">=1.20,<1.26", markers = "python_version != \"3.4\""} +urllib3 = {version = ">=1.25.4,<1.27", markers = "python_version != \"3.4\""} [[package]] name = "bson" @@ -123,14 +123,14 @@ six = ">=1.9.0" [[package]] name = "cattrs" -version = "1.7.1" +version = "1.8.0" description = "Composable complex class support for attrs and dataclasses." category = "main" -optional = true +optional = false python-versions = ">=3.7,<4.0" [package.dependencies] -attrs = ">=20.1.0" +attrs = ">=20" [[package]] name = "certifi" @@ -201,14 +201,6 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" toml = ["toml"] [[package]] -name = "dataclasses" -version = "0.8" -description = "A backport of the dataclasses module for Python 3.6" -category = "dev" -optional = false -python-versions = ">=3.6, <3.7" - -[[package]] name = "distlib" version = "0.3.2" description = "Distribution utilities" @@ -288,7 +280,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "importlib-metadata" -version = "4.6.3" +version = "4.6.4" description = "Read metadata from Python packages" category = "dev" optional = false @@ -304,21 +296,6 @@ perf = ["ipython"] testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] [[package]] -name = "importlib-resources" -version = "5.2.2" -description = "Read resources from Python packages" -category = "dev" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} - -[package.extras] -docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-black (>=0.3.7)", "pytest-mypy"] - -[[package]] name = "iniconfig" version = "1.1.1" description = "iniconfig: brain-dead simple config-ini parsing" @@ -582,7 +559,6 @@ python-versions = ">=3.6.1" cfgv = ">=2.0.0" identify = ">=1.0.0" importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} -importlib-resources = {version = "*", markers = "python_version < \"3.7\""} nodeenv = ">=0.11.1" pyyaml = ">=5.1" toml = "*" @@ -830,7 +806,6 @@ python-versions = ">=3.6,<4.0" [package.dependencies] colorama = ">=0.4.0,<0.5.0" commonmark = ">=0.9.0,<0.10.0" -dataclasses = {version = ">=0.7,<0.9", markers = "python_version >= \"3.6\" and python_version < \"3.7\""} pygments = ">=2.6.0,<3.0.0" typing-extensions = {version = ">=3.7.4,<4.0.0", markers = "python_version < \"3.8\""} @@ -1127,7 +1102,7 @@ six = "*" [[package]] name = "urllib3" -version = "1.25.11" +version = "1.26.6" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "main" optional = false @@ -1151,7 +1126,6 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" distlib = ">=0.3.1,<1" filelock = ">=3.0.0,<4" importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} -importlib-resources = {version = ">=1.0", markers = "python_version < \"3.7\""} platformdirs = ">=2,<3" six = ">=1.9.0,<2" @@ -1172,19 +1146,19 @@ docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] [extras] -all = ["boto3", "cattrs", "pymongo", "redis", "ujson"] -bson = ["cattrs", "bson"] +all = ["boto3", "botocore", "pymongo", "redis", "ujson"] +bson = ["bson"] docs = ["furo", "linkify-it-py", "myst-parser", "Sphinx", "sphinx-autodoc-typehints", "sphinx-copybutton", "sphinx-inline-tabs", "sphinxcontrib-apidoc"] dynamodb = ["boto3", "botocore"] -json = ["cattrs", "ujson"] -mongodb = ["cattrs", "pymongo"] +json = ["ujson"] +mongodb = ["pymongo"] redis = ["redis"] -yaml = ["cattrs"] +yaml = [] [metadata] lock-version = "1.1" -python-versions = "^3.6" -content-hash = "f4a4396f6b035c649a4032f91c7be8a7dc66f17604f0a5993a3a1dc7957fa186" +python-versions = "^3.7" +content-hash = "d766957ab49962cd19a270f70dcecba509dec7283eb54faeb264399b0f795530" [metadata.files] alabaster = [ @@ -1217,19 +1191,19 @@ beautifulsoup4 = [ {file = "beautifulsoup4-4.9.3.tar.gz", hash = "sha256:84729e322ad1d5b4d25f805bfa05b902dd96450f43842c4e99067d5e1369eb25"}, ] boto3 = [ - {file = "boto3-1.15.18-py2.py3-none-any.whl", hash = "sha256:9ab957090f7893172768bb8b8d2c5cce0afd36a9d36d73a9fb14168f72d75a8b"}, - {file = "boto3-1.15.18.tar.gz", hash = "sha256:f56148e2c6b9a2d704218da42f07d72f00270bfddb13bc1bdea20d3327daa51e"}, + {file = "boto3-1.16.63-py2.py3-none-any.whl", hash = "sha256:1c0003609e63e8cff51dee7a49e904bcdb20e140b5f7a10a03006289fd8c8dc1"}, + {file = "boto3-1.16.63.tar.gz", hash = "sha256:c919dac9773115025e1e2a7e462f60ca082e322bb6f4354247523e4226133b0b"}, ] botocore = [ - {file = "botocore-1.18.18-py2.py3-none-any.whl", hash = "sha256:de5f9fc0c7e88ee7ba831fa27475be258ae09ece99143ed623d3618a3c84ee2c"}, - {file = "botocore-1.18.18.tar.gz", hash = "sha256:e224754230e7e015836ba20037cac6321e8e2ce9b8627c14d579fcb37249decd"}, + {file = "botocore-1.19.63-py2.py3-none-any.whl", hash = "sha256:ad4adfcc195b5401d84b0c65d3a89e507c1d54c201879c8761ff10ef5c361e21"}, + {file = "botocore-1.19.63.tar.gz", hash = "sha256:d3694f6ef918def8082513e5ef309cd6cd83b612e9984e3a66e8adc98c650a92"}, ] bson = [ {file = "bson-0.5.10.tar.gz", hash = "sha256:d6511b2ab051139a9123c184de1a04227262173ad593429d21e443d6462d6590"}, ] cattrs = [ - {file = "cattrs-1.7.1-py3-none-any.whl", hash = "sha256:d69bd4a3239e189f0740c3c41178dd0f00e4eac3bcb806937e49942fa83adfee"}, - {file = "cattrs-1.7.1.tar.gz", hash = "sha256:95265b8aaa45e6de75b5f52ae081e021a2a7a688babdb711e4174e6b18920d08"}, + {file = "cattrs-1.8.0-py3-none-any.whl", hash = "sha256:901fb2040529ae8fc9d93f48a2cdf7de3e983312ffb2a164ffa4e9847f253af1"}, + {file = "cattrs-1.8.0.tar.gz", hash = "sha256:5c121ab06a7cac494813c228721a7feb5a6423b17316eeaebf13f5a03e5b0d53"}, ] certifi = [ {file = "certifi-2021.5.30-py2.py3-none-any.whl", hash = "sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8"}, @@ -1309,10 +1283,6 @@ coverage = [ {file = "coverage-5.5-pp37-none-any.whl", hash = "sha256:2a3859cb82dcbda1cfd3e6f71c27081d18aa251d20a17d87d26d4cd216fb0af4"}, {file = "coverage-5.5.tar.gz", hash = "sha256:ebe78fe9a0e874362175b02371bdfbee64d8edc42a044253ddf4ee7d3c15212c"}, ] -dataclasses = [ - {file = "dataclasses-0.8-py3-none-any.whl", hash = "sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf"}, - {file = "dataclasses-0.8.tar.gz", hash = "sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97"}, -] distlib = [ {file = "distlib-0.3.2-py2.py3-none-any.whl", hash = "sha256:23e223426b28491b1ced97dc3bbe183027419dfc7982b4fa2f05d5f3ff10711c"}, {file = "distlib-0.3.2.zip", hash = "sha256:106fef6dc37dd8c0e2c0a60d3fca3e77460a48907f335fa28420463a6f799736"}, @@ -1346,12 +1316,8 @@ imagesize = [ {file = "imagesize-1.2.0.tar.gz", hash = "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1"}, ] importlib-metadata = [ - {file = "importlib_metadata-4.6.3-py3-none-any.whl", hash = "sha256:51c6635429c77cf1ae634c997ff9e53ca3438b495f10a55ba28594dd69764a8b"}, - {file = "importlib_metadata-4.6.3.tar.gz", hash = "sha256:0645585859e9a6689c523927a5032f2ba5919f1f7d0e84bd4533312320de1ff9"}, -] -importlib-resources = [ - {file = "importlib_resources-5.2.2-py3-none-any.whl", hash = "sha256:2480d8e07d1890056cb53c96e3de44fead9c62f2ba949b0f2e4c4345f4afa977"}, - {file = "importlib_resources-5.2.2.tar.gz", hash = "sha256:a65882a4d0fe5fbf702273456ba2ce74fe44892c25e42e057aca526b702a6d4b"}, + {file = "importlib_metadata-4.6.4-py3-none-any.whl", hash = "sha256:ed5157fef23a4bc4594615a0dd8eba94b2bb36bf2a343fa3d8bb2fa0a62a99d5"}, + {file = "importlib_metadata-4.6.4.tar.gz", hash = "sha256:7b30a78db2922d78a6f47fb30683156a14f3c6aa5cc23f77cc8967e9ab2d002f"}, ] iniconfig = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, @@ -1900,8 +1866,8 @@ url-normalize = [ {file = "url_normalize-1.4.3-py2.py3-none-any.whl", hash = "sha256:ec3c301f04e5bb676d333a7fa162fa977ad2ca04b7e652bfc9fac4e405728eed"}, ] urllib3 = [ - {file = "urllib3-1.25.11-py2.py3-none-any.whl", hash = "sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e"}, - {file = "urllib3-1.25.11.tar.gz", hash = "sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2"}, + {file = "urllib3-1.26.6-py2.py3-none-any.whl", hash = "sha256:39fb8672126159acb139a7718dd10806104dec1e2f0f6c88aab05d17df10c8d4"}, + {file = "urllib3-1.26.6.tar.gz", hash = "sha256:f57b4c16c62fa2760b7e3d97c35b255512fb6b59a259730f36ba32ce9f8e342f"}, ] virtualenv = [ {file = "virtualenv-20.7.2-py2.py3-none-any.whl", hash = "sha256:e4670891b3a03eb071748c569a87cceaefbf643c5bac46d996c5a45c34aa0f06"}, diff --git a/pyproject.toml b/pyproject.toml index 80900f4..9357d40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "requests-cache" -version = "0.7.4" +version = "0.8.0" description = "A transparent, persistent cache for the requests library" authors = ["Roman Haritonov", "Jordan Cook"] license = "BSD License" @@ -20,21 +20,20 @@ include = [ "Documentation" = "https://requests-cache.readthedocs.io" [tool.poetry.dependencies] -python = "^3.6" +python = "^3.7" attrs = "^21.2" -itsdangerous = ">=2.0.1" +cattrs = "^1.8" +itsdangerous = ">=2.0" requests = "^2.17" url-normalize = "^1.4" # Optional serialization dependencies -# Note: cattrs will be a hard dependency in a future release, after dropping python 3.6 support bson = {version = ">=0.5", optional = true} -cattrs = {version = "^1.7", python = "^3.7", optional = true} ujson = {version = ">=4.0", optional = true} # Optional backend dependencies -boto3 = { version = "<1.16", optional = true } -botocore = { version = "<1.19", optional = true } +boto3 = { version = "~=1.16.0", optional = true } +botocore = { version = "~=1.19.0", optional = true } pymongo = { version = "^3.0", optional = true } pyyaml = {version = ">=5.4", optional = true} redis = { version = "^3.0", optional = true } @@ -50,21 +49,21 @@ sphinxcontrib-apidoc = { version = "^0.3", optional = true } linkify-it-py = {version = "^1.0.1", optional = true} [tool.poetry.extras] -all = ["boto3", "cattrs", "pymongo", "redis", "ujson"] -bson = ["cattrs", "bson"] # BSON comes with pymongo, and can also be used as a standalone codec -json = ["cattrs", "ujson"] -yaml = ["cattrs", "yaml"] +all = ["boto3", "botocore", "pymongo", "redis", "ujson"] +bson = ["bson"] # BSON comes with pymongo, and can also be used as a standalone codec +json = ["ujson"] +yaml = ["yaml"] dynamodb = ["boto3", "botocore"] -mongodb = ["cattrs", "pymongo"] +mongodb = ["pymongo"] redis = ["redis"] docs = ["furo", "linkify-it-py", "myst-parser", "sphinx", "sphinx-autodoc-typehints", "sphinx-copybutton", "sphinx-inline-tabs", "sphinxcontrib-apidoc"] [tool.poetry.dev-dependencies] -nox = {version = "^2021.6.12", python = "^3.6.2"} -nox-poetry = {version = "^0.8.6", python = "^3.6.2"} -pre-commit = {version = "^2.12", python = "^3.6.2"} mypy = "^0.910" +nox = "^2021.6.12" +nox-poetry = "^0.8.6" +pre-commit = "^2.12" psutil = "^5.0" pytest = "^6.2" pytest-clarity = "^1.0.1" diff --git a/requests_cache/__init__.py b/requests_cache/__init__.py index 7214a42..1854c38 100644 --- a/requests_cache/__init__.py +++ b/requests_cache/__init__.py @@ -5,7 +5,7 @@ logger = getLogger(__name__) # Version is defined in pyproject.toml. # It's copied here to make it easier for client code to check the installed version. -__version__ = '0.7.4' +__version__ = '0.8.0' def get_placeholder_class(original_exception: Exception = None): diff --git a/requests_cache/models/response.py b/requests_cache/models/response.py index ecd5d12..74dd7f7 100755 --- a/requests_cache/models/response.py +++ b/requests_cache/models/response.py @@ -112,12 +112,6 @@ class CachedResponse(Response): """Get the size of the response body in bytes""" return len(self.content) if self.content else 0 - def __getstate__(self): - """Override pickling behavior in ``requests.Response.__getstate__``; - only required for python 3.6 - """ - return self.__dict__ - def __str__(self): return ( f'request: {self.request}, response: {self.status_code} ' diff --git a/requests_cache/serializers/__init__.py b/requests_cache/serializers/__init__.py index b0f9613..e3fa6de 100644 --- a/requests_cache/serializers/__init__.py +++ b/requests_cache/serializers/__init__.py @@ -1,9 +1,13 @@ # flake8: noqa: F401 -import pickle -from warnings import warn - -from .. import get_placeholder_class +from .cattrs import CattrStage from .pipeline import SerializerPipeline, Stage +from .preconf import ( + bson_serializer, + json_serializer, + pickle_serializer, + safe_pickle_serializer, + yaml_serializer, +) __all__ = [ 'SERIALIZERS', @@ -18,26 +22,6 @@ __all__ = [ 'init_serializer', ] -# If cattrs isn't installed, use plain pickle for pickle_serializer, and placeholders for the rest. -# Additional checks for format-specific optional libraries are handled in the preconf module. -try: - from .cattrs import CattrStage - from .preconf import ( - bson_serializer, - json_serializer, - pickle_serializer, - safe_pickle_serializer, - yaml_serializer, - ) -except ImportError as e: - CattrStage = get_placeholder_class(e) # type: ignore - bson_serializer = get_placeholder_class(e) - json_serializer = get_placeholder_class(e) - pickle_serializer = pickle # type: ignore - safe_pickle_serializer = get_placeholder_class(e) - yaml_serializer = get_placeholder_class(e) - - SERIALIZERS = { 'bson': bson_serializer, 'json': json_serializer, diff --git a/requests_cache/serializers/cattrs.py b/requests_cache/serializers/cattrs.py index cd4bcca..9613092 100644 --- a/requests_cache/serializers/cattrs.py +++ b/requests_cache/serializers/cattrs.py @@ -15,7 +15,7 @@ class CattrStage(Stage): ``cattrs``. This does the majority of the work needed for any other serialization format, breaking down objects into python builtin types. - This can be used as a stage within a :py:class:`.SerializerPipeline`. Requires python 3.7+. + This can be used as a stage within a :py:class:`.SerializerPipeline`. """ def __init__(self, factory: Callable[..., GenConverter] = None): diff --git a/requests_cache/serializers/preconf.py b/requests_cache/serializers/preconf.py index 995d3c3..3e558a2 100644 --- a/requests_cache/serializers/preconf.py +++ b/requests_cache/serializers/preconf.py @@ -7,8 +7,6 @@ format's ``dumps()`` (or equivalent) method. For any optional libraries that aren't installed, the corresponding serializer will be a placeholder class that raises an ``ImportError`` at initialization time instead of at import time. - -Requires python 3.7+. """ import pickle from functools import partial diff --git a/tests/integration/test_compat.py b/tests/integration/test_compat.py index a6b9248..b767eea 100644 --- a/tests/integration/test_compat.py +++ b/tests/integration/test_compat.py @@ -1,4 +1,3 @@ -import sys from shutil import copyfile import pytest @@ -7,9 +6,6 @@ from requests_cache import CachedSession from tests.conftest import HTTPBIN_FORMATS, SAMPLE_CACHE_FILES -@pytest.mark.skipif( - sys.version_info < (3, 7), reason='Cache files saved under python 3.7+ are incompatible with 3.6' -) @pytest.mark.parametrize('db_path', SAMPLE_CACHE_FILES) def test_version_upgrade(db_path, tempfile_path): """Load SQLite cache files created with older versions of requests-cache. diff --git a/tests/unit/test_serializers.py b/tests/unit/test_serializers.py index aeac0a8..dbaf967 100644 --- a/tests/unit/test_serializers.py +++ b/tests/unit/test_serializers.py @@ -12,10 +12,6 @@ from itsdangerous.exc import BadSignature from requests_cache import CachedResponse, CachedSession, pickle_serializer -pytestmark = pytest.mark.skipif( - sys.version_info < (3, 7), reason='Requires python 3.7+ version of cattrs' -) - def test_stdlib_json(): import requests_cache.serializers.preconf |