From 9cd2bbeb5039f013abcdd24c1486748676e4c312 Mon Sep 17 00:00:00 2001 From: Terence Honles Date: Mon, 8 Nov 2021 14:10:15 +0100 Subject: [PATCH] Update type comments to type annotations (#568) --- .github/workflows/ci.yml | 2 +- changelog.d/568.misc | 1 + django_redis/client/default.py | 4 ++-- django_redis/hash_ring.py | 2 +- django_redis/pool.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelog.d/568.misc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16378e6e..8bd80095 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -179,6 +179,6 @@ jobs: run: | if ! towncrier check; then echo '' - echo "Please add a description of your changes to 'changelog.d/{issue or PR number}.{feature,bugfix,removal}'" + echo "Please add a description of your changes to 'changelog.d/{issue or PR number}.{feature,bugfix,misc,doc,removal}'" exit 1 fi diff --git a/changelog.d/568.misc b/changelog.d/568.misc new file mode 100644 index 00000000..5fe0165d --- /dev/null +++ b/changelog.d/568.misc @@ -0,0 +1 @@ +Update type comments to type annotations. diff --git a/django_redis/client/default.py b/django_redis/client/default.py index eb62d8ec..1df90a27 100644 --- a/django_redis/client/default.py +++ b/django_redis/client/default.py @@ -42,7 +42,7 @@ def __init__(self, server, params: Dict[str, Any], backend: BaseCache) -> None: if not isinstance(self._server, (list, tuple, set)): self._server = self._server.split(",") - self._clients = [None] * len(self._server) # type: List[Optional[Redis]] + self._clients: List[Optional[Redis]] = [None] * len(self._server) self._options = params.get("OPTIONS", {}) self._replica_read_only = self._options.get("REPLICA_READ_ONLY", True) @@ -146,7 +146,7 @@ def set( timeout = self._backend.default_timeout original_client = client - tried = [] # type: List[int] + tried: List[int] = [] while True: try: if client is None: diff --git a/django_redis/hash_ring.py b/django_redis/hash_ring.py index 5260b275..be456f7e 100644 --- a/django_redis/hash_ring.py +++ b/django_redis/hash_ring.py @@ -4,7 +4,7 @@ class HashRing: - nodes = [] # type: List[str] + nodes: List[str] = [] def __init__(self, nodes: Iterable[str] = (), replicas: int = 128) -> None: self.replicas: int = replicas diff --git a/django_redis/pool.py b/django_redis/pool.py index 0cbd0592..dda3b945 100644 --- a/django_redis/pool.py +++ b/django_redis/pool.py @@ -17,7 +17,7 @@ class ConnectionFactory: # ConnectionFactory is instantiated, as Django creates new cache client # (DefaultClient) instance for every request. - _pools = {} # type: Dict[str, Redis] + _pools: Dict[str, Redis] = {} def __init__(self, options): pool_cls_path = options.get(