Skip to content

back to Claude Sonnet 3.5 - Fill-in summary

Claude Sonnet 3.5 - Fill-in: cachetools

Pytest Summary for test tests

status count
passed 179
failed 36
total 215
collected 215

Failed pytests:

test_func.py::FIFODecoratorTest::test_decorator

test_func.py::FIFODecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_clear

test_func.py::FIFODecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_nocache

test_func.py::FIFODecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_typed

test_func.py::FIFODecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_unbound

test_func.py::FIFODecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_user_function

test_func.py::FIFODecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::LFUDecoratorTest::test_decorator

test_func.py::LFUDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_clear

test_func.py::LFUDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_nocache

test_func.py::LFUDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_typed

test_func.py::LFUDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_unbound

test_func.py::LFUDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_user_function

test_func.py::LFUDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::LRUDecoratorTest::test_decorator

test_func.py::LRUDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_clear

test_func.py::LRUDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_nocache

test_func.py::LRUDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_typed

test_func.py::LRUDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_unbound

test_func.py::LRUDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_user_function

test_func.py::LRUDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::MRUDecoratorTest::test_decorator

test_func.py::MRUDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_clear

test_func.py::MRUDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_nocache

test_func.py::MRUDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_typed

test_func.py::MRUDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_unbound

test_func.py::MRUDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_user_function

test_func.py::MRUDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::RRDecoratorTest::test_decorator

test_func.py::RRDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::RRDecoratorTest::test_decorator_clear

test_func.py::RRDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::RRDecoratorTest::test_decorator_nocache

test_func.py::RRDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::RRDecoratorTest::test_decorator_typed

test_func.py::RRDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::RRDecoratorTest::test_decorator_unbound

test_func.py::RRDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::RRDecoratorTest::test_decorator_user_function

test_func.py::RRDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::TTLDecoratorTest::test_decorator

test_func.py::TTLDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_clear

test_func.py::TTLDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_nocache

test_func.py::TTLDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_typed

test_func.py::TTLDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_unbound

test_func.py::TTLDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_user_function

test_func.py::TTLDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

Patch diff

diff --git a/src/cachetools/func.py b/src/cachetools/func.py
index 338ef94..c0afea5 100644
--- a/src/cachetools/func.py
+++ b/src/cachetools/func.py
@@ -25,7 +25,7 @@ def fifo_cache(maxsize=128, typed=False):
     algorithm.

     """
-    pass
+    return cached(cache=FIFOCache(maxsize), key=keys.typedkey if typed else keys.hashkey)


 def lfu_cache(maxsize=128, typed=False):
@@ -34,7 +34,7 @@ def lfu_cache(maxsize=128, typed=False):
     algorithm.

     """
-    pass
+    return cached(cache=LFUCache(maxsize), key=keys.typedkey if typed else keys.hashkey)


 def lru_cache(maxsize=128, typed=False):
@@ -43,7 +43,7 @@ def lru_cache(maxsize=128, typed=False):
     algorithm.

     """
-    pass
+    return cached(cache=LRUCache(maxsize), key=keys.typedkey if typed else keys.hashkey)


 def mru_cache(maxsize=128, typed=False):
@@ -51,7 +51,7 @@ def mru_cache(maxsize=128, typed=False):
     up to `maxsize` results based on a Most Recently Used (MRU)
     algorithm.
     """
-    pass
+    return cached(cache=MRUCache(maxsize), key=keys.typedkey if typed else keys.hashkey)


 def rr_cache(maxsize=128, choice=random.choice, typed=False):
@@ -60,7 +60,7 @@ def rr_cache(maxsize=128, choice=random.choice, typed=False):
     algorithm.

     """
-    pass
+    return cached(cache=RRCache(maxsize, choice=choice), key=keys.typedkey if typed else keys.hashkey)


 def ttl_cache(maxsize=128, ttl=600, timer=time.monotonic, typed=False):
@@ -68,4 +68,4 @@ def ttl_cache(maxsize=128, ttl=600, timer=time.monotonic, typed=False):
     up to `maxsize` results based on a Least Recently Used (LRU)
     algorithm with a per-item time-to-live (TTL) value.
     """
-    pass
+    return cached(cache=TTLCache(maxsize, ttl, timer), key=keys.typedkey if typed else keys.hashkey)
diff --git a/src/cachetools/keys.py b/src/cachetools/keys.py
index ed97ffd..5404d80 100644
--- a/src/cachetools/keys.py
+++ b/src/cachetools/keys.py
@@ -32,19 +32,24 @@ _kwmark = _HashedTuple,

 def hashkey(*args, **kwargs):
     """Return a cache key for the specified hashable arguments."""
-    pass
+    if kwargs:
+        return _HashedTuple(args + sum(sorted(kwargs.items()), _kwmark))
+    else:
+        return _HashedTuple(args)


 def methodkey(self, *args, **kwargs):
     """Return a cache key for use with cached methods."""
-    pass
+    return hashkey(self.__class__, *args, **kwargs)


 def typedkey(*args, **kwargs):
     """Return a typed cache key for the specified hashable arguments."""
-    pass
+    key = hashkey(*args, **kwargs)
+    return _HashedTuple(tuple(type(arg) for arg in args) + (key,))


 def typedmethodkey(self, *args, **kwargs):
     """Return a typed cache key for use with cached methods."""
-    pass
+    key = methodkey(self, *args, **kwargs)
+    return _HashedTuple((self.__class__,) + tuple(type(arg) for arg in args) + (key,))