From 7ffc08bbfebb081735f3f84b85df87256e8c849d Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Fri, 15 Mar 2024 13:59:26 +0330 Subject: [PATCH] use slots for dataclasses --- pyglossary/glossary_v2.py | 2 +- pyglossary/plugins/appledict_bin/appledict_properties.py | 2 +- pyglossary/plugins/babylon_bgl/bgl_language.py | 2 +- pyglossary/plugins/quickdic6.py | 1 - pyglossary/sort_keys.py | 2 +- scripts/wiktextract/extract-schema.py | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pyglossary/glossary_v2.py b/pyglossary/glossary_v2.py index ca51e40b6..b0eaefbc5 100644 --- a/pyglossary/glossary_v2.py +++ b/pyglossary/glossary_v2.py @@ -95,7 +95,7 @@ # ] -@dataclass(frozen=True) +@dataclass(slots=True, frozen=True) class ConvertArgs: inputFilename: str inputFormat: str = "" diff --git a/pyglossary/plugins/appledict_bin/appledict_properties.py b/pyglossary/plugins/appledict_bin/appledict_properties.py index 978a3f909..8a78af925 100644 --- a/pyglossary/plugins/appledict_bin/appledict_properties.py +++ b/pyglossary/plugins/appledict_bin/appledict_properties.py @@ -18,7 +18,7 @@ __all__ = ["AppleDictProperties", "from_metadata"] -@dataclass +@dataclass(slots=True) class AppleDictProperties: # in plist file: "IDXDictionaryVersion" # values := (1 | 2 | 3) diff --git a/pyglossary/plugins/babylon_bgl/bgl_language.py b/pyglossary/plugins/babylon_bgl/bgl_language.py index c0195054a..84f3c054b 100644 --- a/pyglossary/plugins/babylon_bgl/bgl_language.py +++ b/pyglossary/plugins/babylon_bgl/bgl_language.py @@ -118,7 +118,7 @@ __all__ = ["BabylonLanguage", "languageByCode"] -@dataclass +@dataclass(slots=True) class BabylonLanguage: """ diff --git a/pyglossary/plugins/quickdic6.py b/pyglossary/plugins/quickdic6.py index 4520be071..b161845c9 100644 --- a/pyglossary/plugins/quickdic6.py +++ b/pyglossary/plugins/quickdic6.py @@ -514,7 +514,6 @@ def _without_dash(a: str) -> str: return a.replace("-", "").replace("þ", "th").replace("Þ", "Th") -# TODO: switch to dataclass class QuickDic: def __init__( # noqa: PLR0913 self, diff --git a/pyglossary/sort_keys.py b/pyglossary/sort_keys.py index d451f2f72..c0e057704 100644 --- a/pyglossary/sort_keys.py +++ b/pyglossary/sort_keys.py @@ -44,7 +44,7 @@ class NamedSortKey(NamedTuple): sqlite: "sqliteSortKeyType" -@dataclass +@dataclass(slots=True) class LocaleNamedSortKey: name: str desc: str diff --git a/scripts/wiktextract/extract-schema.py b/scripts/wiktextract/extract-schema.py index a7efe86ba..7bc821f8d 100644 --- a/scripts/wiktextract/extract-schema.py +++ b/scripts/wiktextract/extract-schema.py @@ -6,7 +6,7 @@ from typing import Any -@dataclass +@dataclass(slots=True) class Node: Type: str = ""