diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-08-10 11:43:00 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-08-10 12:16:17 -0400 |
commit | 57cc786e960319708044f55834f35312ca55d05b (patch) | |
tree | b86fdef7ae1105403cf58896699b19ab230458ef | |
parent | dbf57e4a7b8f4061b735be8b24bbb880fb75802f (diff) | |
download | dogpile-cache-57cc786e960319708044f55834f35312ca55d05b.tar.gz |
update black and add to flake8
also pin versions for zimports / flake8,
fix some things for mypy
Change-Id: Ia619e5ae9ffcf95b4546e2b320e5186402c15467
-rw-r--r-- | .pre-commit-config.yaml | 12 | ||||
-rw-r--r-- | dogpile/cache/backends/memcached.py | 25 | ||||
-rw-r--r-- | dogpile/cache/backends/redis.py | 5 | ||||
-rw-r--r-- | tests/cache/test_region.py | 2 | ||||
-rw-r--r-- | tox.ini | 7 |
5 files changed, 24 insertions, 27 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b91e807..cd2bf19 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,24 +2,26 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/python/black - rev: 20.8b1 + rev: 21.5b1 hooks: - id: black - repo: https://github.com/sqlalchemyorg/zimports - rev: master + rev: v0.4.0 hooks: - id: zimports + args: + - --keep-unused-type-checking - repo: https://github.com/pycqa/flake8 - rev: master + rev: 3.9.2 hooks: - id: flake8 additional_dependencies: - flake8-import-order - flake8-builtins - - flake8-docstrings + - flake8-docstrings>=1.3.1 - flake8-rst-docstrings - - pydocstyle<4.0.0 + - pydocstyle - pygments diff --git a/dogpile/cache/backends/memcached.py b/dogpile/cache/backends/memcached.py index 1618500..e512941 100644 --- a/dogpile/cache/backends/memcached.py +++ b/dogpile/cache/backends/memcached.py @@ -18,16 +18,17 @@ from ..api import NO_VALUE from ... import util if typing.TYPE_CHECKING: + import bmemcached import memcache import pylibmc - import bmemcached import pymemcache -else: + +if not typing.TYPE_CHECKING: # delayed import - memcache = None - pylibmc = None - bmemcached = None - pymemcache = None + bmemcached = None # noqa F811 + memcache = None # noqa F811 + pylibmc = None # noqa F811 + pymemcache = None # noqa F811 __all__ = ( "GenericMemcachedBackend", @@ -234,9 +235,6 @@ class MemcacheArgs(GenericMemcachedBackend): super(MemcacheArgs, self).__init__(arguments) -pylibmc = None - - class PylibmcBackend(MemcacheArgs, GenericMemcachedBackend): """A backend for the `pylibmc <http://sendapatch.se/projects/pylibmc/index.html>`_ @@ -286,9 +284,6 @@ class PylibmcBackend(MemcacheArgs, GenericMemcachedBackend): ) -memcache = None - - class MemcachedBackend(MemcacheArgs, GenericMemcachedBackend): """A backend using the standard `Python-memcached <http://www.tummy.com/Community/software/\ @@ -317,9 +312,6 @@ class MemcachedBackend(MemcacheArgs, GenericMemcachedBackend): return memcache.Client(self.url) -bmemcached = None - - class BMemcachedBackend(GenericMemcachedBackend): """A backend for the `python-binary-memcached <https://github.com/jaysonsantos/\ @@ -430,9 +422,6 @@ class BMemcachedBackend(GenericMemcachedBackend): self.delete(key) -pymemcache = None - - class PyMemcacheBackend(GenericMemcachedBackend): """A backend for the `pymemcache <https://github.com/pinterest/pymemcache>`_ diff --git a/dogpile/cache/backends/redis.py b/dogpile/cache/backends/redis.py index f789381..aff4825 100644 --- a/dogpile/cache/backends/redis.py +++ b/dogpile/cache/backends/redis.py @@ -16,9 +16,10 @@ from ..api import NO_VALUE if typing.TYPE_CHECKING: import redis -else: + +if not typing.TYPE_CHECKING: # delayed import - redis = None + redis = None # noqa F811 __all__ = ("RedisBackend", "RedisSentinelBackend") diff --git a/tests/cache/test_region.py b/tests/cache/test_region.py index 0a10beb..2bf5c58 100644 --- a/tests/cache/test_region.py +++ b/tests/cache/test_region.py @@ -757,7 +757,7 @@ class ProxyBackendTest(TestCase): class UsedKeysProxy(ProxyBackend): - """ Keep a counter of hose often we set a particular key""" + """Keep a counter of hose often we set a particular key""" def __init__(self, *args, **kwargs): super(ProxyBackendTest.UsedKeysProxy, self).__init__( @@ -58,6 +58,8 @@ deps= redis Mako decorator + types-redis + types-decorator commands = mypy ./dogpile/ # thanks to https://julien.danjou.info/the-best-flake8-extensions/ @@ -71,4 +73,7 @@ deps= flake8-rst-docstrings # used by flake8-rst-docstrings pygments -commands = flake8 ./dogpile/ ./tests/ setup.py {posargs} + black==21.5b1 +commands = + flake8 ./dogpile/ ./tests/ setup.py {posargs} + black --check . |