Skip to content

Commit d3757f2

Browse files
committed
refactor(fonts): type mutable class defaults
1 parent ea7afcc commit d3757f2

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

weblate/fonts/forms.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from __future__ import annotations
66

7-
from typing import cast
7+
from typing import ClassVar, cast
88

99
from django import forms
1010

@@ -16,8 +16,7 @@ class FontForm(forms.ModelForm):
1616
class Meta:
1717
model = Font
1818
fields = ("font",)
19-
# ruff: ignore[mutable-class-default]
20-
field_classes = {"font": AssetFileField}
19+
field_classes: ClassVar[dict[str, type[forms.Field]]] = {"font": AssetFileField}
2120

2221

2322
class FontGroupForm(forms.ModelForm):

weblate/fonts/models.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# SPDX-License-Identifier: GPL-3.0-or-later
44

5+
from typing import ClassVar
6+
57
from django.conf import settings
68
from django.core.exceptions import ValidationError
79
from django.core.files.storage import FileSystemStorage
@@ -45,7 +47,9 @@ class Font(models.Model, UserDisplayMixin):
4547
)
4648

4749
class Meta:
48-
unique_together = [("family", "style", "project")] # ruff: ignore[mutable-class-default]
50+
unique_together: ClassVar[list[tuple[str, str, str]]] = [
51+
("family", "style", "project")
52+
]
4953
verbose_name = "Font"
5054
verbose_name_plural = "Fonts"
5155

@@ -126,7 +130,7 @@ class FontGroup(models.Model):
126130
objects = FontGroupQuerySet.as_manager()
127131

128132
class Meta:
129-
unique_together = [("project", "name")] # ruff: ignore[mutable-class-default]
133+
unique_together: ClassVar[list[tuple[str, str]]] = [("project", "name")]
130134
verbose_name = "Font group"
131135
verbose_name_plural = "Font groups"
132136

@@ -153,7 +157,7 @@ class FontOverride(models.Model):
153157
)
154158

155159
class Meta:
156-
unique_together = [("group", "language")] # ruff: ignore[mutable-class-default]
160+
unique_together: ClassVar[list[tuple[str, str]]] = [("group", "language")]
157161
verbose_name = "Font override"
158162
verbose_name_plural = "Font overrides"
159163

0 commit comments

Comments
 (0)