From 42986838cffc0dc5bd2a7ec6edd67875eb6d999c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 8 Nov 2024 19:23:25 +0100 Subject: [PATCH] chore: avoid subclassing dict, list and str Identified by subclass-builtin (FURB189) ruff check. --- weblate/trans/checklists.py | 4 +++- weblate/trans/models/project.py | 4 +++- weblate/utils/render.py | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/weblate/trans/checklists.py b/weblate/trans/checklists.py index c2a88cbf522d..364b454f5c53 100644 --- a/weblate/trans/checklists.py +++ b/weblate/trans/checklists.py @@ -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: diff --git a/weblate/trans/models/project.py b/weblate/trans/models/project.py index 0cc671dc7fe0..8b6df734b10b 100644 --- a/weblate/trans/models/project.py +++ b/weblate/trans/models/project.py @@ -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 @@ -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): diff --git a/weblate/utils/render.py b/weblate/utils/render.py index 93c47c7ad206..0f60b964e2c2 100644 --- a/weblate/utils/render.py +++ b/weblate/utils/render.py @@ -4,6 +4,7 @@ from __future__ import annotations +from collections import UserString from typing import TYPE_CHECKING from django.conf import settings @@ -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)