aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Kemmer <tkemmer@computer.org>2021-09-30 12:12:13 +0200
committerThomas Kemmer <tkemmer@computer.org>2021-09-30 12:12:21 +0200
commitc234536941a0e81cb28b12685ff8b76b4a05ed96 (patch)
treed944f296a5d3731d57376093481931ec90f5a365
parentbc998ba4278e06f19ab0270c42b8ff7af6448cab (diff)
downloadcachetools-c234536941a0e81cb28b12685ff8b76b4a05ed96.tar.gz
Fix #225: Add submodule shims for backward compatibility.
-rw-r--r--setup.cfg4
-rw-r--r--src/cachetools/cache.py7
-rw-r--r--src/cachetools/fifo.py7
-rw-r--r--src/cachetools/lfu.py7
-rw-r--r--src/cachetools/lru.py7
-rw-r--r--src/cachetools/mru.py7
-rw-r--r--src/cachetools/rr.py7
-rw-r--r--src/cachetools/ttl.py7
-rw-r--r--tests/test_deprecated.py67
9 files changed, 119 insertions, 1 deletions
diff --git a/setup.cfg b/setup.cfg
index 9f3f926..143aba1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -36,7 +36,9 @@ where = src
max-line-length = 80
exclude = .git, .tox, build
select = C, E, F, W, B, B950, I, N
-ignore = E501, W503
+# F401: imported but unused (submodule shims)
+# E501: line too long (black)
+ignore = F401, E501
[build_sphinx]
source-dir = docs/
diff --git a/src/cachetools/cache.py b/src/cachetools/cache.py
new file mode 100644
index 0000000..8c9dfd7
--- /dev/null
+++ b/src/cachetools/cache.py
@@ -0,0 +1,7 @@
+import warnings
+
+from . import Cache
+
+warnings.warn(
+ "cachetools.cache is deprecated, please use cachetools.Cache", DeprecationWarning
+)
diff --git a/src/cachetools/fifo.py b/src/cachetools/fifo.py
new file mode 100644
index 0000000..ec072cd
--- /dev/null
+++ b/src/cachetools/fifo.py
@@ -0,0 +1,7 @@
+import warnings
+
+from . import FIFOCache
+
+warnings.warn(
+ "cachetools.fifo is deprecated, please use cachetools.FIFOCache", DeprecationWarning
+)
diff --git a/src/cachetools/lfu.py b/src/cachetools/lfu.py
new file mode 100644
index 0000000..44514ac
--- /dev/null
+++ b/src/cachetools/lfu.py
@@ -0,0 +1,7 @@
+import warnings
+
+from . import LFUCache
+
+warnings.warn(
+ "cachetools.lfu is deprecated, please use cachetools.LFUCache", DeprecationWarning
+)
diff --git a/src/cachetools/lru.py b/src/cachetools/lru.py
new file mode 100644
index 0000000..5d557b0
--- /dev/null
+++ b/src/cachetools/lru.py
@@ -0,0 +1,7 @@
+import warnings
+
+from . import LRUCache
+
+warnings.warn(
+ "cachetools.lru is deprecated, please use cachetools.LRUCache", DeprecationWarning
+)
diff --git a/src/cachetools/mru.py b/src/cachetools/mru.py
new file mode 100644
index 0000000..0714bdc
--- /dev/null
+++ b/src/cachetools/mru.py
@@ -0,0 +1,7 @@
+import warnings
+
+from . import MRUCache
+
+warnings.warn(
+ "cachetools.mru is deprecated, please use cachetools.MRUCache", DeprecationWarning
+)
diff --git a/src/cachetools/rr.py b/src/cachetools/rr.py
new file mode 100644
index 0000000..f49e185
--- /dev/null
+++ b/src/cachetools/rr.py
@@ -0,0 +1,7 @@
+import warnings
+
+from . import RRCache
+
+warnings.warn(
+ "cachetools.rr is deprecated, please use cachetools.RRCache", DeprecationWarning
+)
diff --git a/src/cachetools/ttl.py b/src/cachetools/ttl.py
new file mode 100644
index 0000000..d96b677
--- /dev/null
+++ b/src/cachetools/ttl.py
@@ -0,0 +1,7 @@
+import warnings
+
+from . import TTLCache
+
+warnings.warn(
+ "cachetools.ttl is deprecated, please use cachetools.TTLCache", DeprecationWarning
+)
diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py
new file mode 100644
index 0000000..6510c82
--- /dev/null
+++ b/tests/test_deprecated.py
@@ -0,0 +1,67 @@
+import unittest
+import warnings
+
+
+class DeprecatedTest(unittest.TestCase):
+ def test_cache(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ from cachetools.cache import Cache
+
+ assert len(w) == 1
+ assert issubclass(w[-1].category, DeprecationWarning)
+ assert "cachetools.cache" in str(w[-1].message)
+
+ def test_fifo(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ from cachetools.fifo import FIFOCache
+
+ assert len(w) == 1
+ assert issubclass(w[-1].category, DeprecationWarning)
+ assert "cachetools.fifo" in str(w[-1].message)
+
+ def test_lfu(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ from cachetools.lfu import LFUCache
+
+ assert len(w) == 1
+ assert issubclass(w[-1].category, DeprecationWarning)
+ assert "cachetools.lfu" in str(w[-1].message)
+
+ def test_lru(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ from cachetools.lru import LRUCache
+
+ assert len(w) == 1
+ assert issubclass(w[-1].category, DeprecationWarning)
+ assert "cachetools.lru" in str(w[-1].message)
+
+ def test_mru(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ from cachetools.mru import MRUCache
+
+ assert len(w) == 1
+ assert issubclass(w[-1].category, DeprecationWarning)
+ assert "cachetools.mru" in str(w[-1].message)
+
+ def test_rr(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ from cachetools.rr import RRCache
+
+ assert len(w) == 1
+ assert issubclass(w[-1].category, DeprecationWarning)
+ assert "cachetools.rr" in str(w[-1].message)
+
+ def test_ttl(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ from cachetools.ttl import TTLCache
+
+ assert len(w) == 1
+ assert issubclass(w[-1].category, DeprecationWarning)
+ assert "cachetools.ttl" in str(w[-1].message)