Skip to content

Commit 57cc786

Browse files
committed
update black and add to flake8
also pin versions for zimports / flake8, fix some things for mypy Change-Id: Ia619e5ae9ffcf95b4546e2b320e5186402c15467
1 parent dbf57e4 commit 57cc786

5 files changed

Lines changed: 24 additions & 27 deletions

File tree

.pre-commit-config.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/python/black
5-
rev: 20.8b1
5+
rev: 21.5b1
66
hooks:
77
- id: black
88

99
- repo: https://github.com/sqlalchemyorg/zimports
10-
rev: master
10+
rev: v0.4.0
1111
hooks:
1212
- id: zimports
13+
args:
14+
- --keep-unused-type-checking
1315

1416
- repo: https://github.com/pycqa/flake8
15-
rev: master
17+
rev: 3.9.2
1618
hooks:
1719
- id: flake8
1820
additional_dependencies:
1921
- flake8-import-order
2022
- flake8-builtins
21-
- flake8-docstrings
23+
- flake8-docstrings>=1.3.1
2224
- flake8-rst-docstrings
23-
- pydocstyle<4.0.0
25+
- pydocstyle
2426
- pygments
2527

dogpile/cache/backends/memcached.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@
1818
from ... import util
1919

2020
if typing.TYPE_CHECKING:
21+
import bmemcached
2122
import memcache
2223
import pylibmc
23-
import bmemcached
2424
import pymemcache
25-
else:
25+
26+
if not typing.TYPE_CHECKING:
2627
# delayed import
27-
memcache = None
28-
pylibmc = None
29-
bmemcached = None
30-
pymemcache = None
28+
bmemcached = None # noqa F811
29+
memcache = None # noqa F811
30+
pylibmc = None # noqa F811
31+
pymemcache = None # noqa F811
3132

3233
__all__ = (
3334
"GenericMemcachedBackend",
@@ -234,9 +235,6 @@ def __init__(self, arguments):
234235
super(MemcacheArgs, self).__init__(arguments)
235236

236237

237-
pylibmc = None
238-
239-
240238
class PylibmcBackend(MemcacheArgs, GenericMemcachedBackend):
241239
"""A backend for the
242240
`pylibmc <http://sendapatch.se/projects/pylibmc/index.html>`_
@@ -286,9 +284,6 @@ def _create_client(self):
286284
)
287285

288286

289-
memcache = None
290-
291-
292287
class MemcachedBackend(MemcacheArgs, GenericMemcachedBackend):
293288
"""A backend using the standard
294289
`Python-memcached <http://www.tummy.com/Community/software/\
@@ -317,9 +312,6 @@ def _create_client(self):
317312
return memcache.Client(self.url)
318313

319314

320-
bmemcached = None
321-
322-
323315
class BMemcachedBackend(GenericMemcachedBackend):
324316
"""A backend for the
325317
`python-binary-memcached <https://github.com/jaysonsantos/\
@@ -430,9 +422,6 @@ def delete_multi(self, keys):
430422
self.delete(key)
431423

432424

433-
pymemcache = None
434-
435-
436425
class PyMemcacheBackend(GenericMemcachedBackend):
437426
"""A backend for the
438427
`pymemcache <https://github.com/pinterest/pymemcache>`_

dogpile/cache/backends/redis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
if typing.TYPE_CHECKING:
1818
import redis
19-
else:
19+
20+
if not typing.TYPE_CHECKING:
2021
# delayed import
21-
redis = None
22+
redis = None # noqa F811
2223

2324
__all__ = ("RedisBackend", "RedisSentinelBackend")
2425

tests/cache/test_region.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def set(self, key, value):
757757

758758
class UsedKeysProxy(ProxyBackend):
759759

760-
""" Keep a counter of hose often we set a particular key"""
760+
"""Keep a counter of hose often we set a particular key"""
761761

762762
def __init__(self, *args, **kwargs):
763763
super(ProxyBackendTest.UsedKeysProxy, self).__init__(

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ deps=
5858
redis
5959
Mako
6060
decorator
61+
types-redis
62+
types-decorator
6163
commands = mypy ./dogpile/
6264

6365
# thanks to https://julien.danjou.info/the-best-flake8-extensions/
@@ -71,4 +73,7 @@ deps=
7173
flake8-rst-docstrings
7274
# used by flake8-rst-docstrings
7375
pygments
74-
commands = flake8 ./dogpile/ ./tests/ setup.py {posargs}
76+
black==21.5b1
77+
commands =
78+
flake8 ./dogpile/ ./tests/ setup.py {posargs}
79+
black --check .

0 commit comments

Comments
 (0)