Skip to content

Commit

Permalink
fix(component): avoid crash on getting unused enforcements
Browse files Browse the repository at this point in the history
Fixes #12701
  • Loading branch information
nijel committed Oct 8, 2024
1 parent 3c5dc2a commit 773d94b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion weblate/trans/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@
from weblate.vcs.ssh import add_host_key

if TYPE_CHECKING:
from collections.abc import Iterable
from datetime import datetime

from weblate.addons.models import Addon
from weblate.auth.models import AuthenticatedHttpRequest, User
from weblate.checks.base import BaseCheck
from weblate.trans.models import Unit

NEW_LANG_CHOICES = (
Expand Down Expand Up @@ -3747,14 +3749,15 @@ def _schedule_sync_terminology(self) -> None:
for glossary in self.project.glossaries:
sync_glossary_languages.delay(glossary.pk)

def get_unused_enforcements(self):
def get_unused_enforcements(self) -> Iterable[dict | BaseCheck]:
from weblate.trans.models import Unit

for current in self.enforced_checks:
try:
check = CHECKS[current]
except KeyError:
yield {"name": current, "notsupported": True}
continue

Check warning on line 3760 in weblate/trans/models/component.py

View check run for this annotation

Codecov / codecov/patch

weblate/trans/models/component.py#L3760

Added line #L3760 was not covered by tests
# Check is always enabled
if not check.default_disabled:
continue
Expand Down

0 comments on commit 773d94b

Please sign in to comment.