Skip to content

Commit

Permalink
chore: avoid subclassing dict, list and str
Browse files Browse the repository at this point in the history
Identified by subclass-builtin (FURB189) ruff check.
  • Loading branch information
nijel committed Nov 8, 2024
1 parent 9f6381e commit 4298683
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion weblate/trans/checklists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

from collections import UserList

from weblate.trans.filter import FILTERS


class TranslationChecklist(list):
class TranslationChecklist(UserList):
"""Simple list wrapper for translation checklist."""

def add_if(self, stats, name, level) -> None:
Expand Down
4 changes: 3 additions & 1 deletion weblate/trans/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import os.path
from collections import UserDict
from datetime import datetime
from operator import itemgetter
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -48,8 +49,9 @@
from weblate.trans.models.translation import TranslationQuerySet


class ProjectLanguageFactory(dict):
class ProjectLanguageFactory(UserDict):
def __init__(self, project: Project) -> None:
super().__init__()
self._project = project

def __getitem__(self, key: Language):
Expand Down
5 changes: 2 additions & 3 deletions weblate/utils/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from __future__ import annotations

from collections import UserString
from typing import TYPE_CHECKING

from django.conf import settings
Expand All @@ -20,9 +21,7 @@
from django.core.validators import URLValidator


class InvalidString(str):
__slots__ = ()

class InvalidString(UserString):
def __mod__(self, other: str):
raise TemplateSyntaxError(gettext('Undefined variable: "%s"') % other)

Expand Down

0 comments on commit 4298683

Please sign in to comment.