diff --git a/caching/cache.py b/caching/cache.py index ea29a76..798deda 100644 --- a/caching/cache.py +++ b/caching/cache.py @@ -1,3 +1,4 @@ +# -*- coding: future_fstrings -*- import pickle from collections import OrderedDict from functools import wraps @@ -65,14 +66,14 @@ def __init__( results only in case of the exceptions are raisd in the decorated function. """ - self.params = OrderedDict( - maxsize=maxsize, - ttl=ttl, - filepath=filepath, - policy=policy, - key=key, - only_on_errors=only_on_errors, - **kwargs, + self.params = OrderedDict([ + ('maxsize', maxsize), + ('ttl', ttl), + ('filepath', filepath), + ('policy', policy), + ('key', key), + ('only_on_errors', only_on_errors)] + + list(kwargs.items()) ) self.only_on_errors = only_on_errors self.make_key = key @@ -84,10 +85,8 @@ def __init__( ) def __repr__(self): - return ( - f"{self.__class__.__name__}" - f"({', '.join(f'{k}={repr(v)}' for k,v in self.params.items())})" - ) + param_str = ', '.join(f'{k}={repr(v)}' for k, v in self.params.items()) + return f'{self.__class__.__name__}({param_str})' def _decorator(self, fn): if not callable(fn): diff --git a/caching/storage.py b/caching/storage.py index f2d4b42..0ee5392 100644 --- a/caching/storage.py +++ b/caching/storage.py @@ -1,3 +1,4 @@ +# -*- coding: future_fstrings -*- import os import sqlite3 from contextlib import suppress @@ -92,10 +93,8 @@ def __repr__(self): (p, getattr(self, p)) for p in ('filepath', 'maxsize', 'ttl') ) - return ( - f'{self.__class__.__name__}' - f"({', '.join(f'{k}={repr(v)}' for k,v in params)})" - ) + param_str = ', '.join(f'{k}={repr(v)}' for k, v in params) + return f'{self.__class__.__name__}({param_str})' def __enter__(self): self.init_db() @@ -152,11 +151,12 @@ def init_db(self): ''') with self.db as db: + addnl_col_str = ''.join(f"{c}, " for c in policy_stuff['additional_columns']) db.execute(f''' CREATE TABLE IF NOT EXISTS cache ( key BINARY PRIMARY KEY, ts REAL NOT NULL DEFAULT ({self.SQLITE_TIMESTAMP}), - {''.join(f"{c}, " for c in policy_stuff['additional_columns'])} + {addnl_col_str} value BLOB NOT NULL ) WITHOUT ROWID ''') diff --git a/setup.py b/setup.py index 6f6ccc3..f52cead 100644 --- a/setup.py +++ b/setup.py @@ -55,9 +55,12 @@ def run_tests(self): 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', ], + install_requires=['future-fstrings'], + setup_requires=['future-fstrings'], tests_require=['pytest'], cmdclass={'test': PyTest}, ) diff --git a/tests/test_cache.py b/tests/test_cache.py index f2d604e..33368b3 100644 --- a/tests/test_cache.py +++ b/tests/test_cache.py @@ -1,3 +1,4 @@ +# -*- coding: future_fstrings -*- import os import time diff --git a/tests/test_storage_sqlite.py b/tests/test_storage_sqlite.py index 6ff72fd..d34e2b0 100644 --- a/tests/test_storage_sqlite.py +++ b/tests/test_storage_sqlite.py @@ -1,3 +1,4 @@ +# -*- coding: future_fstrings -*- import os import pytest