Skip to content

Commit

Permalink
chore(utils): fix type annotations for WeblateLock class
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Jun 24, 2024
1 parent eb8e9f1 commit 2ff9670
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions weblate/utils/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

import os
from contextlib import suppress
from typing import cast

import sentry_sdk
from django.core.cache import cache
from django_redis.cache import RedisCache
from filelock import FileLock, Timeout
from redis_lock import AlreadyAcquired, NotAcquired

Expand All @@ -29,7 +31,7 @@ def __init__(
key: int,
slug: str,
cache_template: str = "lock:{scope}:{key}",
file_template: str | None = "{slug}-{scope}.lock",
file_template: str = "{slug}-{scope}.lock",
timeout: int = 1,
) -> None:
self._timeout = timeout
Expand All @@ -41,7 +43,7 @@ def __init__(
if is_redis_cache():
# Prefer Redis locking as it works distributed
self._name = self._format_template(cache_template)
self._lock = cache.lock(
self._lock = cast(RedisCache, cache).lock(
key=self._name,
expire=3600,
auto_renewal=True,
Expand Down

0 comments on commit 2ff9670

Please sign in to comment.