From 05d7f0acaed55e5dc420b514350be55b64c0dab8 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Thu, 26 Oct 2023 11:00:12 +0100 Subject: [PATCH] chore: Fix RUF012 --- src/djangocms_snippet/admin.py | 10 ++++++---- src/djangocms_snippet/models.py | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/djangocms_snippet/admin.py b/src/djangocms_snippet/admin.py index c0f46fd6..5c34d7a7 100644 --- a/src/djangocms_snippet/admin.py +++ b/src/djangocms_snippet/admin.py @@ -1,3 +1,5 @@ +from typing import Any, ClassVar + from django.conf import settings from django.contrib import admin from django.db import models @@ -16,16 +18,16 @@ class Media: ) list_display = ("slug", "name") - search_fields = ["slug", "name"] - prepopulated_fields = {"slug": ("name",)} + search_fields: ClassVar[list[str]] = ["slug", "name"] + prepopulated_fields: ClassVar[dict[str, list[str]]] = {"slug": ("name",)} change_form_template = "djangocms_snippet/admin/change_form.html" - text_area_attrs = { + text_area_attrs: ClassVar[dict[str, Any]] = { "rows": 20, "data-editor": True, "data-mode": getattr(settings, "DJANGOCMS_SNIPPET_THEME", "html"), "data-theme": getattr(settings, "DJANGOCMS_SNIPPET_MODE", "github"), } - formfield_overrides = { + formfield_overrides: ClassVar[dict[Any, dict[str, Any]]] = { models.TextField: {"widget": Textarea(attrs=text_area_attrs)} } diff --git a/src/djangocms_snippet/models.py b/src/djangocms_snippet/models.py index e5bf69ad..692f1bad 100644 --- a/src/djangocms_snippet/models.py +++ b/src/djangocms_snippet/models.py @@ -1,3 +1,5 @@ +from typing import ClassVar + from cms.models import CMSPlugin from django.conf import settings from django.db import models @@ -43,7 +45,7 @@ class Snippet(models.Model): ) class Meta: - ordering = ["name"] + ordering: ClassVar[list[str]] = ["name"] verbose_name = _("Snippet") verbose_name_plural = _("Snippets")