diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-11-14 10:54:58 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-11-14 10:54:58 -0500 |
commit | 04d45d73e850de23431b69ac989ed9c270f267da (patch) | |
tree | 79df9ceba8283057cea47070e444620ca208faf4 | |
parent | 8cc7e8d184168f36fb05cac96834ea7ec35fb8a0 (diff) | |
download | dogpile-cache-04d45d73e850de23431b69ac989ed9c270f267da.tar.gz |
update black and set for python 3.6
Change-Id: I0c2fbb5e577c956c3d3f80abeb910ec6f546cb23
-rw-r--r-- | .pre-commit-config.yaml | 2 | ||||
-rw-r--r-- | docs/build/conf.py | 8 | ||||
-rw-r--r-- | dogpile/cache/backends/__init__.py | 5 | ||||
-rw-r--r-- | dogpile/cache/backends/redis.py | 6 | ||||
-rw-r--r-- | dogpile/cache/proxy.py | 2 | ||||
-rw-r--r-- | dogpile/cache/region.py | 2 | ||||
-rw-r--r-- | dogpile/util/nameregistry.py | 5 | ||||
-rw-r--r-- | pyproject.toml | 2 | ||||
-rw-r--r-- | setup.py | 4 | ||||
-rw-r--r-- | tests/cache/plugins/test_mako_cache.py | 2 | ||||
-rw-r--r-- | tests/cache/test_decorator.py | 2 | ||||
-rw-r--r-- | tests/cache/test_mako.py | 33 | ||||
-rw-r--r-- | tests/cache/test_region.py | 8 | ||||
-rw-r--r-- | tests/test_lock.py | 16 | ||||
-rw-r--r-- | tests/test_utils.py | 3 |
15 files changed, 52 insertions, 48 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9a60df..b91e807 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/python/black - rev: 19.10b0 + rev: 20.8b1 hooks: - id: black diff --git a/docs/build/conf.py b/docs/build/conf.py index bce7ada..0dda560 100644 --- a/docs/build/conf.py +++ b/docs/build/conf.py @@ -64,8 +64,8 @@ source_suffix = ".rst" master_doc = "index" # General information about the project. -project = u"dogpile.cache" -copyright = u"2011-2020 Mike Bayer" +project = "dogpile.cache" +copyright = "2011-2020 Mike Bayer" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -217,8 +217,8 @@ latex_documents = [ ( "index", "dogpile.cache.tex", - u"Dogpile.Cache Documentation", - u"Mike Bayer", + "Dogpile.Cache Documentation", + "Mike Bayer", "manual", ) ] diff --git a/dogpile/cache/backends/__init__.py b/dogpile/cache/backends/__init__.py index 6b1c1fd..fcd1357 100644 --- a/dogpile/cache/backends/__init__.py +++ b/dogpile/cache/backends/__init__.py @@ -36,6 +36,7 @@ register_backend( "dogpile.cache.redis", "dogpile.cache.backends.redis", "RedisBackend" ) register_backend( - "dogpile.cache.redis_sentinel", "dogpile.cache.backends.redis", - "RedisSentinelBackend" + "dogpile.cache.redis_sentinel", + "dogpile.cache.backends.redis", + "RedisSentinelBackend", ) diff --git a/dogpile/cache/backends/redis.py b/dogpile/cache/backends/redis.py index d886165..f789381 100644 --- a/dogpile/cache/backends/redis.py +++ b/dogpile/cache/backends/redis.py @@ -174,7 +174,9 @@ class RedisBackend(BytesBackend): def set_serialized(self, key, value): if self.redis_expiration_time: self.writer_client.setex( - key, self.redis_expiration_time, value, + key, + self.redis_expiration_time, + value, ) else: self.writer_client.set(key, value) @@ -307,7 +309,7 @@ class RedisSentinelBackend(RedisBackend): sentinel = redis.sentinel.Sentinel( self.sentinels, sentinel_kwargs=sentinel_kwargs, - **connection_kwargs + **connection_kwargs, ) self.writer_client = sentinel.master_for(self.service_name) self.reader_client = sentinel.slave_for(self.service_name) diff --git a/dogpile/cache/proxy.py b/dogpile/cache/proxy.py index 0958838..0b57edb 100644 --- a/dogpile/cache/proxy.py +++ b/dogpile/cache/proxy.py @@ -67,7 +67,7 @@ class ProxyBackend(CacheBackend): pass def wrap(self, backend: CacheBackend) -> "ProxyBackend": - """ Take a backend as an argument and setup the self.proxied property. + """Take a backend as an argument and setup the self.proxied property. Return an object that be used as a backend by a :class:`.CacheRegion` object. """ diff --git a/dogpile/cache/region.py b/dogpile/cache/region.py index c1e19ef..273a1c8 100644 --- a/dogpile/cache/region.py +++ b/dogpile/cache/region.py @@ -1753,7 +1753,7 @@ class CacheRegion: key_generator: Callable[..., Sequence[KeyType]], user_func: Callable[..., Sequence[ValuePayload]], *arg: Any, - **kw: Any + **kw: Any, ) -> Union[Sequence[ValuePayload], Mapping[KeyType, ValuePayload]]: cache_keys = arg keys = key_generator(*arg, **kw) diff --git a/dogpile/util/nameregistry.py b/dogpile/util/nameregistry.py index a320ec2..3c4cc02 100644 --- a/dogpile/util/nameregistry.py +++ b/dogpile/util/nameregistry.py @@ -44,10 +44,7 @@ class NameRegistry(object): _mutex = threading.RLock() def __init__(self, creator: Callable[..., Any]): - """Create a new :class:`.NameRegistry`. - - - """ + """Create a new :class:`.NameRegistry`.""" self._values: MutableMapping[str, Any] = weakref.WeakValueDictionary() self._mutex = threading.RLock() self.creator = creator diff --git a/pyproject.toml b/pyproject.toml index 486bbe6..50a9b52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.black] line-length = 79 -target-version = ['py27'] +target-version = ['py36'] @@ -19,4 +19,6 @@ class UseTox(TestCommand): sys.exit(1) -setup(cmdclass={"test": UseTox},) +setup( + cmdclass={"test": UseTox}, +) diff --git a/tests/cache/plugins/test_mako_cache.py b/tests/cache/plugins/test_mako_cache.py index 1837ff3..5ef81dd 100644 --- a/tests/cache/plugins/test_mako_cache.py +++ b/tests/cache/plugins/test_mako_cache.py @@ -47,7 +47,7 @@ class TestMakoPlugin(TestCase): </%def> ${mydef()} """, - **kw + **kw, ) t.render() eq_(reg.get_or_create.call_args[1], {"expiration_time": 20}) diff --git a/tests/cache/test_decorator.py b/tests/cache/test_decorator.py index 946b042..5de351d 100644 --- a/tests/cache/test_decorator.py +++ b/tests/cache/test_decorator.py @@ -462,7 +462,7 @@ class KeyGenerationTest(TestCase): def test_sha1_key_mangler_unicode_py2k(self): eq_( - util.sha1_mangle_key(u"some_key"), + util.sha1_mangle_key("some_key"), "53def077a4264bd3183d4eb21b1f56f883e1b572", ) diff --git a/tests/cache/test_mako.py b/tests/cache/test_mako.py index e816e72..6e2ce35 100644 --- a/tests/cache/test_mako.py +++ b/tests/cache/test_mako.py @@ -1,17 +1,16 @@ -from unittest import TestCase
-
-
-class MakoTest(TestCase):
-
- """ Test entry point for Mako
- """
-
- def test_entry_point(self):
- import pkg_resources
-
- # if the entrypoint isn't there, just pass, as the tests can be run
- # without any setuptools install
- for impl in pkg_resources.iter_entry_points(
- "mako.cache", "dogpile.cache"
- ):
- impl.load()
+from unittest import TestCase + + +class MakoTest(TestCase): + + """Test entry point for Mako""" + + def test_entry_point(self): + import pkg_resources + + # if the entrypoint isn't there, just pass, as the tests can be run + # without any setuptools install + for impl in pkg_resources.iter_entry_points( + "mako.cache", "dogpile.cache" + ): + impl.load() diff --git a/tests/cache/test_region.py b/tests/cache/test_region.py index 7168433..1665540 100644 --- a/tests/cache/test_region.py +++ b/tests/cache/test_region.py @@ -531,9 +531,9 @@ class RegionTest(TestCase): class ProxyRegionTest(RegionTest): - """ This is exactly the same as the region test above, but it goes through + """This is exactly the same as the region test above, but it goes through a dummy proxy. The purpose of this is to make sure the tests still run - successfully even when there is a proxy """ + successfully even when there is a proxy""" class MockProxy(ProxyBackend): @property @@ -737,8 +737,8 @@ class ProxyBackendTest(TestCase): class NeverSetProxy(ProxyBackend): - """ A totally contrived example of a Proxy that we pass arguments to. - Never set a key that matches never_set """ + """A totally contrived example of a Proxy that we pass arguments to. + Never set a key that matches never_set""" def __init__(self, never_set, *args, **kwargs): super(ProxyBackendTest.NeverSetProxy, self).__init__( diff --git a/tests/test_lock.py b/tests/test_lock.py index 71dd192..8e1acc4 100644 --- a/tests/test_lock.py +++ b/tests/test_lock.py @@ -282,13 +282,17 @@ class ConcurrencyTest(TestCase): assert not failures[0], "%s failures occurred" % failures[0] assert actual_run_time <= expected_run_time - assert slow_waiters[0] <= expected_slow_waiters, ( - "Number of slow waiters %s exceeds expected slow waiters %s" - % (slow_waiters[0], expected_slow_waiters) + assert ( + slow_waiters[0] <= expected_slow_waiters + ), "Number of slow waiters %s exceeds expected slow waiters %s" % ( + slow_waiters[0], + expected_slow_waiters, ) - assert len(the_resource) <= expected_generations, ( - "Number of resource generations %d exceeded " - "expected %d" % (len(the_resource), expected_generations) + assert ( + len(the_resource) <= expected_generations + ), "Number of resource generations %d exceeded " "expected %d" % ( + len(the_resource), + expected_generations, ) diff --git a/tests/test_utils.py b/tests/test_utils.py index 64442c7..853027f 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,8 +5,7 @@ from dogpile import util class UtilsTest(TestCase): - """ Test the relevant utils functionality. - """ + """Test the relevant utils functionality.""" def test_coerce_string_conf(self): settings = {"expiration_time": "-1"} |