Hello community,

here is the log from the commit of package python-cachetools for 
openSUSE:Factory checked in at 2020-05-01 11:06:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-cachetools (Old)
 and      /work/SRC/openSUSE:Factory/.python-cachetools.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-cachetools"

Fri May  1 11:06:40 2020 rev:9 rq:798870 version:4.1.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-cachetools/python-cachetools.changes      
2020-04-19 21:36:03.202464892 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-cachetools.new.2738/python-cachetools.changes
    2020-05-01 11:06:49.158994878 +0200
@@ -1,0 +2,10 @@
+Wed Apr 29 10:47:20 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 4.1.0:
+  - Support ``user_function`` with ``cachetools.func`` decorators
+    (Python 3.8 compatibility).
+  
+  - Support ``cache_parameters()`` with ``cachetools.func`` decorators
+    (Python 3.9 compatibility).
+
+-------------------------------------------------------------------

Old:
----
  cachetools-4.0.0.tar.gz

New:
----
  cachetools-4.1.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-cachetools.spec ++++++
--- /var/tmp/diff_new_pack.Ao2DPc/_old  2020-05-01 11:06:50.690998209 +0200
+++ /var/tmp/diff_new_pack.Ao2DPc/_new  2020-05-01 11:06:50.694998218 +0200
@@ -19,7 +19,7 @@
 %define skip_python2 1
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-cachetools
-Version:        4.0.0
+Version:        4.1.0
 Release:        0
 Summary:        Extensible memoizing collections and decorators
 License:        MIT

++++++ cachetools-4.0.0.tar.gz -> cachetools-4.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/CHANGELOG.rst 
new/cachetools-4.1.0/CHANGELOG.rst
--- old/cachetools-4.0.0/CHANGELOG.rst  2019-12-15 20:53:38.000000000 +0100
+++ new/cachetools-4.1.0/CHANGELOG.rst  2020-04-08 13:32:37.000000000 +0200
@@ -1,3 +1,13 @@
+v4.1.0 (2020-04-08)
+===================
+
+- Support ``user_function`` with ``cachetools.func`` decorators
+  (Python 3.8 compatibility).
+
+- Support ``cache_parameters()`` with ``cachetools.func`` decorators
+  (Python 3.9 compatibility).
+
+
 v4.0.0 (2019-12-15)
 ===================
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/LICENSE new/cachetools-4.1.0/LICENSE
--- old/cachetools-4.0.0/LICENSE        2019-04-10 19:41:37.000000000 +0200
+++ new/cachetools-4.1.0/LICENSE        2020-04-08 13:32:25.000000000 +0200
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2014-2019 Thomas Kemmer
+Copyright (c) 2014-2020 Thomas Kemmer
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of
 this software and associated documentation files (the "Software"), to deal in
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/PKG-INFO 
new/cachetools-4.1.0/PKG-INFO
--- old/cachetools-4.0.0/PKG-INFO       2019-12-15 20:54:06.000000000 +0100
+++ new/cachetools-4.1.0/PKG-INFO       2020-04-08 13:34:37.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: cachetools
-Version: 4.0.0
+Version: 4.1.0
 Summary: Extensible memoizing collections and decorators
 Home-page: https://github.com/tkem/cachetools/
 Author: Thomas Kemmer
@@ -89,7 +89,7 @@
         License
         
------------------------------------------------------------------------
         
-        Copyright (c) 2014-2019 Thomas Kemmer.
+        Copyright (c) 2014-2020 Thomas Kemmer.
         
         Licensed under the `MIT License`_.
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/README.rst 
new/cachetools-4.1.0/README.rst
--- old/cachetools-4.0.0/README.rst     2019-12-15 20:53:38.000000000 +0100
+++ new/cachetools-4.1.0/README.rst     2020-04-08 13:32:25.000000000 +0200
@@ -81,7 +81,7 @@
 License
 ------------------------------------------------------------------------
 
-Copyright (c) 2014-2019 Thomas Kemmer.
+Copyright (c) 2014-2020 Thomas Kemmer.
 
 Licensed under the `MIT License`_.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/cachetools/__init__.py 
new/cachetools-4.1.0/cachetools/__init__.py
--- old/cachetools-4.0.0/cachetools/__init__.py 2019-12-15 20:53:38.000000000 
+0100
+++ new/cachetools-4.1.0/cachetools/__init__.py 2020-04-08 13:32:25.000000000 
+0200
@@ -17,4 +17,4 @@
     'cachedmethod'
 )
 
-__version__ = '4.0.0'
+__version__ = '4.1.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/cachetools/func.py 
new/cachetools-4.1.0/cachetools/func.py
--- old/cachetools-4.0.0/cachetools/func.py     2019-12-15 20:53:38.000000000 
+0100
+++ new/cachetools-4.1.0/cachetools/func.py     2020-04-08 13:32:25.000000000 
+0200
@@ -26,7 +26,9 @@
 
 class _UnboundCache(dict):
 
-    maxsize = None
+    @property
+    def maxsize(self):
+        return None
 
     @property
     def currsize(self):
@@ -42,26 +44,14 @@
         return None
 
 
-def _cache(cache, typed=False):
+def _cache(cache, typed):
+    maxsize = cache.maxsize
+
     def decorator(func):
         key = keys.typedkey if typed else keys.hashkey
         lock = RLock()
         stats = [0, 0]
 
-        def cache_info():
-            with lock:
-                hits, misses = stats
-                maxsize = cache.maxsize
-                currsize = cache.currsize
-            return _CacheInfo(hits, misses, maxsize, currsize)
-
-        def cache_clear():
-            with lock:
-                try:
-                    cache.clear()
-                finally:
-                    stats[:] = [0, 0]
-
         def wrapper(*args, **kwargs):
             k = key(*args, **kwargs)
             with lock:
@@ -78,9 +68,25 @@
             except ValueError:
                 pass  # value too large
             return v
-        functools.update_wrapper(wrapper, func)
+
+        def cache_info():
+            with lock:
+                hits, misses = stats
+                maxsize = cache.maxsize
+                currsize = cache.currsize
+            return _CacheInfo(hits, misses, maxsize, currsize)
+
+        def cache_clear():
+            with lock:
+                try:
+                    cache.clear()
+                finally:
+                    stats[:] = [0, 0]
+
         wrapper.cache_info = cache_info
         wrapper.cache_clear = cache_clear
+        wrapper.cache_parameters = lambda: {'maxsize': maxsize, 'typed': typed}
+        functools.update_wrapper(wrapper, func)
         return wrapper
     return decorator
 
@@ -93,6 +99,8 @@
     """
     if maxsize is None:
         return _cache(_UnboundCache(), typed)
+    elif callable(maxsize):
+        return _cache(LFUCache(128), typed)(maxsize)
     else:
         return _cache(LFUCache(maxsize), typed)
 
@@ -105,6 +113,8 @@
     """
     if maxsize is None:
         return _cache(_UnboundCache(), typed)
+    elif callable(maxsize):
+        return _cache(LRUCache(128), typed)(maxsize)
     else:
         return _cache(LRUCache(maxsize), typed)
 
@@ -117,6 +127,8 @@
     """
     if maxsize is None:
         return _cache(_UnboundCache(), typed)
+    elif callable(maxsize):
+        return _cache(RRCache(128, choice), typed)(maxsize)
     else:
         return _cache(RRCache(maxsize, choice), typed)
 
@@ -128,5 +140,7 @@
     """
     if maxsize is None:
         return _cache(_UnboundTTLCache(ttl, timer), typed)
+    elif callable(maxsize):
+        return _cache(TTLCache(128, ttl, timer), typed)(maxsize)
     else:
         return _cache(TTLCache(maxsize, ttl, timer), typed)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/cachetools.egg-info/PKG-INFO 
new/cachetools-4.1.0/cachetools.egg-info/PKG-INFO
--- old/cachetools-4.0.0/cachetools.egg-info/PKG-INFO   2019-12-15 
20:54:06.000000000 +0100
+++ new/cachetools-4.1.0/cachetools.egg-info/PKG-INFO   2020-04-08 
13:34:37.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: cachetools
-Version: 4.0.0
+Version: 4.1.0
 Summary: Extensible memoizing collections and decorators
 Home-page: https://github.com/tkem/cachetools/
 Author: Thomas Kemmer
@@ -89,7 +89,7 @@
         License
         
------------------------------------------------------------------------
         
-        Copyright (c) 2014-2019 Thomas Kemmer.
+        Copyright (c) 2014-2020 Thomas Kemmer.
         
         Licensed under the `MIT License`_.
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/docs/conf.py 
new/cachetools-4.1.0/docs/conf.py
--- old/cachetools-4.0.0/docs/conf.py   2019-12-15 20:53:38.000000000 +0100
+++ new/cachetools-4.1.0/docs/conf.py   2020-04-08 13:32:25.000000000 +0200
@@ -9,7 +9,7 @@
 
 
 project = 'cachetools'
-copyright = '2014-2019 Thomas Kemmer'
+copyright = '2014-2020 Thomas Kemmer'
 version = get_version()
 release = version
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/docs/index.rst 
new/cachetools-4.1.0/docs/index.rst
--- old/cachetools-4.0.0/docs/index.rst 2019-12-15 20:53:38.000000000 +0100
+++ new/cachetools-4.1.0/docs/index.rst 2020-04-08 13:32:25.000000000 +0200
@@ -426,31 +426,50 @@
 ``f(3)`` and ``f(3.0)`` will be treated as distinct calls with
 distinct results.
 
-The wrapped function is instrumented with :func:`cache_info` and
+If a `user_function` is specified instead, it must be a callable.
+This allows the decorator to be applied directly to a user function,
+leaving the `maxsize` at its default value of 128::
+
+  @cachetools.func.lru_cache
+  def count_vowels(sentence):
+      sentence = sentence.casefold()
+      return sum(sentence.count(vowel) for vowel in 'aeiou')
+
+The wrapped function is instrumented with a :func:`cache_parameters`
+function that returns a new :class:`dict` showing the values for
+`maxsize` and `typed`.  This is for information purposes only.
+Mutating the values has no effect.
+
+The wrapped function is also instrumented with :func:`cache_info` and
 :func:`cache_clear` functions to provide information about cache
 performance and clear the cache.  Please see the
 :func:`functools.lru_cache` documentation for details.  Also note that
 all the decorators in this module are thread-safe by default.
 
-.. decorator:: lfu_cache(maxsize=128, typed=False)
+
+.. decorator:: lfu_cache(user_function)
+               lfu_cache(maxsize=128, typed=False)
 
    Decorator that wraps a function with a memoizing callable that
    saves up to `maxsize` results based on a Least Frequently Used
    (LFU) algorithm.
 
-.. decorator:: lru_cache(maxsize=128, typed=False)
+.. decorator:: lru_cache(user_function)
+               lru_cache(maxsize=128, typed=False)
 
    Decorator that wraps a function with a memoizing callable that
    saves up to `maxsize` results based on a Least Recently Used (LRU)
    algorithm.
 
-.. decorator:: rr_cache(maxsize=128, choice=random.choice, typed=False)
+.. decorator:: rr_cache(user_function)
+               rr_cache(maxsize=128, choice=random.choice, typed=False)
 
    Decorator that wraps a function with a memoizing callable that
    saves up to `maxsize` results based on a Random Replacement (RR)
    algorithm.
 
-.. decorator:: ttl_cache(maxsize=128, ttl=600, timer=time.monotonic, 
typed=False)
+.. decorator:: ttl_cache(user_function)
+               ttl_cache(maxsize=128, ttl=600, timer=time.monotonic, 
typed=False)
 
    Decorator to wrap a function with a memoizing callable that saves
    up to `maxsize` results based on a Least Recently Used (LRU)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/setup.cfg 
new/cachetools-4.1.0/setup.cfg
--- old/cachetools-4.0.0/setup.cfg      2019-12-15 20:54:06.000000000 +0100
+++ new/cachetools-4.1.0/setup.cfg      2020-04-08 13:34:37.000000000 +0200
@@ -1,6 +1,6 @@
 [metadata]
 name = cachetools
-version = 4.0.0
+version = 4.1.0
 url = https://github.com/tkem/cachetools/
 author = Thomas Kemmer
 author_email = [email protected]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-4.0.0/tests/test_func.py 
new/cachetools-4.1.0/tests/test_func.py
--- old/cachetools-4.0.0/tests/test_func.py     2019-04-10 19:41:37.000000000 
+0200
+++ new/cachetools-4.1.0/tests/test_func.py     2020-04-08 13:32:25.000000000 
+0200
@@ -5,12 +5,14 @@
 
 class DecoratorTestMixin(object):
 
-    def decorator(self, maxsize, typed=False, lock=None):
-        raise NotImplementedError
+    def decorator(self, maxsize, **kwargs):
+        return self.DECORATOR(maxsize, **kwargs)
 
     def test_decorator(self):
         cached = self.decorator(maxsize=2)(lambda n: n)
-
+        self.assertEqual(cached.cache_parameters(), {
+            'maxsize': 2, 'typed': False
+        })
         self.assertEqual(cached.cache_info(), (0, 0, 2, 0))
         self.assertEqual(cached(1), 1)
         self.assertEqual(cached.cache_info(), (0, 1, 2, 1))
@@ -21,7 +23,9 @@
 
     def test_decorator_clear(self):
         cached = self.decorator(maxsize=2)(lambda n: n)
-
+        self.assertEqual(cached.cache_parameters(), {
+            'maxsize': 2, 'typed': False
+        })
         self.assertEqual(cached.cache_info(), (0, 0, 2, 0))
         self.assertEqual(cached(1), 1)
         self.assertEqual(cached.cache_info(), (0, 1, 2, 1))
@@ -32,7 +36,9 @@
 
     def test_decorator_nocache(self):
         cached = self.decorator(maxsize=0)(lambda n: n)
-
+        self.assertEqual(cached.cache_parameters(), {
+            'maxsize': 0, 'typed': False
+        })
         self.assertEqual(cached.cache_info(), (0, 0, 0, 0))
         self.assertEqual(cached(1), 1)
         self.assertEqual(cached.cache_info(), (0, 1, 0, 0))
@@ -43,7 +49,9 @@
 
     def test_decorator_unbound(self):
         cached = self.decorator(maxsize=None)(lambda n: n)
-
+        self.assertEqual(cached.cache_parameters(), {
+            'maxsize': None, 'typed': False
+        })
         self.assertEqual(cached.cache_info(), (0, 0, None, 0))
         self.assertEqual(cached(1), 1)
         self.assertEqual(cached.cache_info(), (0, 1, None, 1))
@@ -54,7 +62,9 @@
 
     def test_decorator_typed(self):
         cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
-
+        self.assertEqual(cached.cache_parameters(), {
+            'maxsize': 2, 'typed': True
+        })
         self.assertEqual(cached.cache_info(), (0, 0, 2, 0))
         self.assertEqual(cached(1), 1)
         self.assertEqual(cached.cache_info(), (0, 1, 2, 1))
@@ -65,26 +75,35 @@
         self.assertEqual(cached(1.0), 1.0)
         self.assertEqual(cached.cache_info(), (2, 2, 2, 2))
 
+    def test_decorator_user_function(self):
+        cached = self.decorator(lambda n: n)
+        self.assertEqual(cached.cache_parameters(), {
+            'maxsize': 128, 'typed': False
+        })
+        self.assertEqual(cached.cache_info(), (0, 0, 128, 0))
+        self.assertEqual(cached(1), 1)
+        self.assertEqual(cached.cache_info(), (0, 1, 128, 1))
+        self.assertEqual(cached(1), 1)
+        self.assertEqual(cached.cache_info(), (1, 1, 128, 1))
+        self.assertEqual(cached(1.0), 1.0)
+        self.assertEqual(cached.cache_info(), (2, 1, 128, 1))
+
 
 class LFUDecoratorTest(unittest.TestCase, DecoratorTestMixin):
 
-    def decorator(self, maxsize, **kwargs):
-        return cachetools.func.lfu_cache(maxsize, **kwargs)
+    DECORATOR = staticmethod(cachetools.func.lfu_cache)
 
 
 class LRUDecoratorTest(unittest.TestCase, DecoratorTestMixin):
 
-    def decorator(self, maxsize, **kwargs):
-        return cachetools.func.lru_cache(maxsize, **kwargs)
+    DECORATOR = staticmethod(cachetools.func.lru_cache)
 
 
 class RRDecoratorTest(unittest.TestCase, DecoratorTestMixin):
 
-    def decorator(self, maxsize, **kwargs):
-        return cachetools.func.rr_cache(maxsize, **kwargs)
+    DECORATOR = staticmethod(cachetools.func.rr_cache)
 
 
 class TTLDecoratorTest(unittest.TestCase, DecoratorTestMixin):
 
-    def decorator(self, maxsize, **kwargs):
-        return cachetools.func.ttl_cache(maxsize, **kwargs)
+    DECORATOR = staticmethod(cachetools.func.ttl_cache)


Reply via email to