Coverage for app/venv/lib/python3.14/site-packages/weblate/checks/tasks.py: 87%
17 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
1# Copyright © Michal Čihař <michal@weblate.org>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5from __future__ import annotations
7from weblate.checks.base import BatchCheckMixin
8from weblate.checks.models import CHECKS
9from weblate.trans.models import Component
10from weblate.utils.celery import app
11from weblate.utils.lock import WeblateLockTimeoutError
14@app.task(
15 trail=False,
16 autoretry_for=(WeblateLockTimeoutError,),
17 retry_backoff=60,
18)
19def batch_update_checks(
20 component_id, checks, component: Component | None = None
21) -> None:
22 if component is None: 22 ↛ 24line 22 didn't jump to line 24 because the condition on line 22 was always true
23 component = Component.objects.get(pk=component_id)
24 with component.lock:
25 for check in checks:
26 check_obj = CHECKS[check]
27 if not isinstance(check_obj, BatchCheckMixin): 27 ↛ 29line 27 didn't jump to line 29 because the condition on line 27 was never true
28 # Should not happen
29 raise TypeError
30 component.log_info("batch updating check %s", check)
31 check_obj.perform_batch(component)