Skip to content

Commit

Permalink
chore: guard against unexpected values
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed May 15, 2024
1 parent dc8e890 commit 82d4db5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions weblate/trans/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,8 @@ def __init__(self, scope, *args, **kwargs) -> None:
languages = Language.objects.filter(
translation__component=scope["component"]
).exclude(pk=scope["component"].source_language_id)
else:
raise ValueError(f"Invalid scope: {scope}")
self.fields["language"].choices += languages.as_choices()

def clean(self) -> None:
Expand Down
2 changes: 2 additions & 0 deletions weblate/utils/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -1915,5 +1915,7 @@ def highlight(self, new: str, old: str) -> str:
template = "<ins>{}</ins>"
elif op == self.DIFF_EQUAL:
template = "{}"
else:
raise ValueError(f"Unsuppoorted operation: {op}")
output.append(format_html(template, data))
return "".join(output)

0 comments on commit 82d4db5

Please sign in to comment.