From 3ba7847e725e47de994f63b377c077c3f0846152 Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Sun, 3 Mar 2024 22:10:15 +0330 Subject: [PATCH 1/2] fix `ruff --preview` errors --- pyglossary/langs/writing_system.py | 2 ++ pyglossary/plugin_manager.py | 1 + pyglossary/plugins/aard2_slob.py | 19 ++++++++------- pyglossary/plugins/abc_medical_notes.py | 16 ++++++------- pyglossary/plugins/almaany.py | 16 ++++++------- pyglossary/plugins/appledict/__init__.py | 16 ++++++------- pyglossary/plugins/appledict_bin/__init__.py | 16 ++++++------- .../appledict_bin/appledict_file_tools.py | 1 + .../plugins/appledict_bin/article_address.py | 1 + pyglossary/plugins/ayandict_sqlite.py | 18 +++++++------- pyglossary/plugins/babylon_bdc.py | 14 +++++------ pyglossary/plugins/babylon_bgl/__init__.py | 24 +++++++++---------- pyglossary/plugins/cc_cedict/__init__.py | 16 ++++++------- pyglossary/plugins/cc_kedict.py | 16 ++++++------- pyglossary/plugins/crawler_dir.py | 18 +++++++------- pyglossary/plugins/csv_plugin.py | 18 +++++++------- pyglossary/plugins/dicformids.py | 18 +++++++------- pyglossary/plugins/dict_cc.py | 16 ++++++------- pyglossary/plugins/dict_cc_split.py | 16 ++++++------- pyglossary/plugins/dict_org.py | 18 +++++++------- pyglossary/plugins/dict_org_source.py | 16 ++++++------- pyglossary/plugins/dictunformat.py | 16 ++++++------- pyglossary/plugins/digitalnk.py | 16 ++++++------- pyglossary/plugins/dikt_json.py | 16 ++++++------- pyglossary/plugins/dsl/__init__.py | 18 +++++++------- pyglossary/plugins/ebook_epub2.py | 16 ++++++------- pyglossary/plugins/ebook_kobo.py | 16 ++++++------- pyglossary/plugins/ebook_kobo_dictfile.py | 18 +++++++------- pyglossary/plugins/ebook_mobi.py | 16 ++++++------- pyglossary/plugins/edlin.py | 18 +++++++------- pyglossary/plugins/freedict.py | 16 ++++++------- pyglossary/plugins/gettext_po.py | 18 +++++++------- pyglossary/plugins/html_dir.py | 16 ++++++------- pyglossary/plugins/info_plugin.py | 18 +++++++------- pyglossary/plugins/iupac_goldbook.py | 16 ++++++------- pyglossary/plugins/jmdict.py | 16 ++++++------- pyglossary/plugins/jmnedict.py | 16 ++++++------- pyglossary/plugins/json_plugin.py | 16 ++++++------- pyglossary/plugins/lingoes_ldf.py | 18 +++++++------- .../plugins/octopus_mdict_new/__init__.py | 16 ++++++------- pyglossary/plugins/quickdic6.py | 20 ++++++++-------- pyglossary/plugins/sql.py | 16 ++++++------- pyglossary/plugins/stardict.py | 18 +++++++------- pyglossary/plugins/stardict_textual.py | 18 +++++++------- pyglossary/plugins/wiktextract.py | 16 ++++++------- pyglossary/plugins/wordnet.py | 16 ++++++------- pyglossary/plugins/wordset.py | 16 ++++++------- pyglossary/plugins/xdxf/__init__.py | 16 ++++++------- pyglossary/plugins/xdxf_lax.py | 16 ++++++------- pyglossary/plugins/yomichan.py | 16 ++++++------- pyglossary/plugins/zimfile.py | 16 ++++++------- pyglossary/slob.py | 3 ++- pyglossary/sort_keys.py | 1 + pyglossary/sq_entry_list.py | 1 - pyglossary/text_utils_extra.py | 5 ++-- pyproject.toml | 2 +- tests/text_utils_extra_test.py | 1 - 57 files changed, 408 insertions(+), 401 deletions(-) diff --git a/pyglossary/langs/writing_system.py b/pyglossary/langs/writing_system.py index abee00a1c..be969ea94 100644 --- a/pyglossary/langs/writing_system.py +++ b/pyglossary/langs/writing_system.py @@ -12,6 +12,7 @@ "writingSystemList", ] + class WritingSystem(NamedTuple): name: str iso: list[tuple[int, str]] | list[tuple[int, str, str]] = [] @@ -26,6 +27,7 @@ class WritingSystem(NamedTuple): # scripts are separated into multiple groups based on their popularity # (usage in multiple live languages, and number of native speakers) + writingSystemList = [ WritingSystem( name="Latin", diff --git a/pyglossary/plugin_manager.py b/pyglossary/plugin_manager.py index 902fc2740..ba9978027 100644 --- a/pyglossary/plugin_manager.py +++ b/pyglossary/plugin_manager.py @@ -39,6 +39,7 @@ log = logging.getLogger("pyglossary") + class DetectedFormat(NamedTuple): filename: str formatName: str diff --git a/pyglossary/plugins/aard2_slob.py b/pyglossary/plugins/aard2_slob.py index ac22ee6a1..d3d8f2079 100644 --- a/pyglossary/plugins/aard2_slob.py +++ b/pyglossary/plugins/aard2_slob.py @@ -22,19 +22,19 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True @@ -110,6 +110,7 @@ t_edition, } + class Reader: depends = { "icu": "PyICU", # >=1.5 diff --git a/pyglossary/plugins/abc_medical_notes.py b/pyglossary/plugins/abc_medical_notes.py index d195e4507..6bc47d9c7 100644 --- a/pyglossary/plugins/abc_medical_notes.py +++ b/pyglossary/plugins/abc_medical_notes.py @@ -11,18 +11,18 @@ __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/almaany.py b/pyglossary/plugins/almaany.py index e577863d9..2f83e474e 100644 --- a/pyglossary/plugins/almaany.py +++ b/pyglossary/plugins/almaany.py @@ -10,18 +10,18 @@ from pyglossary.glossary_types import EntryType, GlossaryType __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/appledict/__init__.py b/pyglossary/plugins/appledict/__init__.py index 540f424e4..20a04f60a 100644 --- a/pyglossary/plugins/appledict/__init__.py +++ b/pyglossary/plugins/appledict/__init__.py @@ -48,18 +48,18 @@ from collections.abc import Generator __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] sys.setrecursionlimit(10000) diff --git a/pyglossary/plugins/appledict_bin/__init__.py b/pyglossary/plugins/appledict_bin/__init__.py index 770270dbc..9328b45e7 100644 --- a/pyglossary/plugins/appledict_bin/__init__.py +++ b/pyglossary/plugins/appledict_bin/__init__.py @@ -65,18 +65,18 @@ from pyglossary.option import BoolOption, Option __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/appledict_bin/appledict_file_tools.py b/pyglossary/plugins/appledict_bin/appledict_file_tools.py index 518d72095..33273809d 100644 --- a/pyglossary/plugins/appledict_bin/appledict_file_tools.py +++ b/pyglossary/plugins/appledict_bin/appledict_file_tools.py @@ -32,6 +32,7 @@ APPLEDICT_FILE_OFFSET = 0x40 # addressing of AppleDict binary files always ignores first 0x40 bytes + def readIntPair(buffer: "io.BufferedIOBase") -> "tuple[int, int]": # to satisfy mymy, put them in vars with declared type a: int diff --git a/pyglossary/plugins/appledict_bin/article_address.py b/pyglossary/plugins/appledict_bin/article_address.py index 9f3c35176..4f08599cd 100644 --- a/pyglossary/plugins/appledict_bin/article_address.py +++ b/pyglossary/plugins/appledict_bin/article_address.py @@ -18,6 +18,7 @@ __all__ = ["ArticleAddress"] + class ArticleAddress(NamedTuple): sectionOffset: int chunkOffset: int diff --git a/pyglossary/plugins/ayandict_sqlite.py b/pyglossary/plugins/ayandict_sqlite.py index 497dd458e..d2b206e2f 100644 --- a/pyglossary/plugins/ayandict_sqlite.py +++ b/pyglossary/plugins/ayandict_sqlite.py @@ -15,19 +15,19 @@ from pyglossary.option import BoolOption, Option __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/babylon_bdc.py b/pyglossary/plugins/babylon_bdc.py index 1470b0f19..1fc9faf9c 100644 --- a/pyglossary/plugins/babylon_bdc.py +++ b/pyglossary/plugins/babylon_bdc.py @@ -6,17 +6,17 @@ from pyglossary.option import Option __all__ = [ - "enable", - "lname", - "format", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", + "singleFile", + "website", + "wiki", ] enable = False diff --git a/pyglossary/plugins/babylon_bgl/__init__.py b/pyglossary/plugins/babylon_bgl/__init__.py index 28f7491be..36b9f0676 100644 --- a/pyglossary/plugins/babylon_bgl/__init__.py +++ b/pyglossary/plugins/babylon_bgl/__init__.py @@ -21,18 +21,18 @@ from .bgl_reader import optionsProp __all__ = [ - "enable", - "lname", - "format", - "description", - "extensions", - "extensionCreate", - "singleFile", - "kind", - "wiki", - "website", - "optionsProp", - "Reader", + "Reader", + "description", + "enable", + "extensionCreate", + "extensions", + "format", + "kind", + "lname", + "optionsProp", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/cc_cedict/__init__.py b/pyglossary/plugins/cc_cedict/__init__.py index 78a44bad4..f55abef7d 100644 --- a/pyglossary/plugins/cc_cedict/__init__.py +++ b/pyglossary/plugins/cc_cedict/__init__.py @@ -19,18 +19,18 @@ __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/cc_kedict.py b/pyglossary/plugins/cc_kedict.py index 2d36ca543..8f8465719 100644 --- a/pyglossary/plugins/cc_kedict.py +++ b/pyglossary/plugins/cc_kedict.py @@ -16,18 +16,18 @@ from pyglossary.text_reader import TextGlossaryReader __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/crawler_dir.py b/pyglossary/plugins/crawler_dir.py index d258b70de..1b69c2160 100644 --- a/pyglossary/plugins/crawler_dir.py +++ b/pyglossary/plugins/crawler_dir.py @@ -20,19 +20,19 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/csv_plugin.py b/pyglossary/plugins/csv_plugin.py index 53e42adca..d0c88887a 100644 --- a/pyglossary/plugins/csv_plugin.py +++ b/pyglossary/plugins/csv_plugin.py @@ -41,19 +41,19 @@ import io __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/dicformids.py b/pyglossary/plugins/dicformids.py index d2eca70be..e71202867 100644 --- a/pyglossary/plugins/dicformids.py +++ b/pyglossary/plugins/dicformids.py @@ -16,19 +16,19 @@ from pyglossary.option import Option __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] lname = "dicformids" diff --git a/pyglossary/plugins/dict_cc.py b/pyglossary/plugins/dict_cc.py index 6e929cdce..36ba9e281 100644 --- a/pyglossary/plugins/dict_cc.py +++ b/pyglossary/plugins/dict_cc.py @@ -15,18 +15,18 @@ from pyglossary.core import log __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/dict_cc_split.py b/pyglossary/plugins/dict_cc_split.py index e2c1b6bb4..8ac2cf0a0 100644 --- a/pyglossary/plugins/dict_cc_split.py +++ b/pyglossary/plugins/dict_cc_split.py @@ -12,18 +12,18 @@ from pyglossary.core import log __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/dict_org.py b/pyglossary/plugins/dict_org.py index 148ece9fc..1e17ee1a5 100644 --- a/pyglossary/plugins/dict_org.py +++ b/pyglossary/plugins/dict_org.py @@ -12,19 +12,19 @@ from pyglossary.plugin_lib.dictdlib import DictDB __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/dict_org_source.py b/pyglossary/plugins/dict_org_source.py index 548b8507b..31b08503b 100644 --- a/pyglossary/plugins/dict_org_source.py +++ b/pyglossary/plugins/dict_org_source.py @@ -6,18 +6,18 @@ from pyglossary.text_utils import replaceStringTable __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/dictunformat.py b/pyglossary/plugins/dictunformat.py index 4b956c971..4cf08db2d 100644 --- a/pyglossary/plugins/dictunformat.py +++ b/pyglossary/plugins/dictunformat.py @@ -3,18 +3,18 @@ from pyglossary.text_reader import TextGlossaryReader __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/digitalnk.py b/pyglossary/plugins/digitalnk.py index 4d381a094..b2fd49d51 100644 --- a/pyglossary/plugins/digitalnk.py +++ b/pyglossary/plugins/digitalnk.py @@ -10,18 +10,18 @@ from pyglossary.glossary_types import EntryType, GlossaryType __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/dikt_json.py b/pyglossary/plugins/dikt_json.py index c194003bf..f7e19cb86 100644 --- a/pyglossary/plugins/dikt_json.py +++ b/pyglossary/plugins/dikt_json.py @@ -17,18 +17,18 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/dsl/__init__.py b/pyglossary/plugins/dsl/__init__.py index 4ba983f54..c56af7cc3 100644 --- a/pyglossary/plugins/dsl/__init__.py +++ b/pyglossary/plugins/dsl/__init__.py @@ -47,18 +47,18 @@ import io __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True @@ -321,7 +321,7 @@ def parseEntryBlock( log.error(err) continue if res is None: - log.error("res is None for line={line!r}") + log.error(f"res is None for line={line!r}") continue term = res.output.strip() terms.append(term) diff --git a/pyglossary/plugins/ebook_epub2.py b/pyglossary/plugins/ebook_epub2.py index 36dae1b4c..168d68995 100644 --- a/pyglossary/plugins/ebook_epub2.py +++ b/pyglossary/plugins/ebook_epub2.py @@ -33,18 +33,18 @@ from pyglossary.glossary_types import GlossaryType __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/ebook_kobo.py b/pyglossary/plugins/ebook_kobo.py index 05759b2ac..c872f2ddb 100644 --- a/pyglossary/plugins/ebook_kobo.py +++ b/pyglossary/plugins/ebook_kobo.py @@ -41,18 +41,18 @@ from pyglossary.option import Option __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/ebook_kobo_dictfile.py b/pyglossary/plugins/ebook_kobo_dictfile.py index 9b3cb6ffa..aa0c810bf 100644 --- a/pyglossary/plugins/ebook_kobo_dictfile.py +++ b/pyglossary/plugins/ebook_kobo_dictfile.py @@ -41,19 +41,19 @@ import io __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/ebook_mobi.py b/pyglossary/plugins/ebook_mobi.py index 3651e7762..639f3168d 100644 --- a/pyglossary/plugins/ebook_mobi.py +++ b/pyglossary/plugins/ebook_mobi.py @@ -44,18 +44,18 @@ from pyglossary.glossary_types import EntryType, GlossaryType __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/edlin.py b/pyglossary/plugins/edlin.py index 726076d43..776fcdbc0 100644 --- a/pyglossary/plugins/edlin.py +++ b/pyglossary/plugins/edlin.py @@ -36,19 +36,19 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/freedict.py b/pyglossary/plugins/freedict.py index 532fe0b64..41d3dc5e7 100644 --- a/pyglossary/plugins/freedict.py +++ b/pyglossary/plugins/freedict.py @@ -30,18 +30,18 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/gettext_po.py b/pyglossary/plugins/gettext_po.py index d536b7332..b0e3e345c 100644 --- a/pyglossary/plugins/gettext_po.py +++ b/pyglossary/plugins/gettext_po.py @@ -17,19 +17,19 @@ import io __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/html_dir.py b/pyglossary/plugins/html_dir.py index 2fc46ae40..289a4da23 100644 --- a/pyglossary/plugins/html_dir.py +++ b/pyglossary/plugins/html_dir.py @@ -30,18 +30,18 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/info_plugin.py b/pyglossary/plugins/info_plugin.py index cb966d60b..874ad74c4 100644 --- a/pyglossary/plugins/info_plugin.py +++ b/pyglossary/plugins/info_plugin.py @@ -17,19 +17,19 @@ from pyglossary.option import Option __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/iupac_goldbook.py b/pyglossary/plugins/iupac_goldbook.py index d3eec6079..fe02eaa63 100644 --- a/pyglossary/plugins/iupac_goldbook.py +++ b/pyglossary/plugins/iupac_goldbook.py @@ -20,18 +20,18 @@ from pyglossary.html_utils import unescape_unicode __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/jmdict.py b/pyglossary/plugins/jmdict.py index 0bc85697e..3a79d85bf 100644 --- a/pyglossary/plugins/jmdict.py +++ b/pyglossary/plugins/jmdict.py @@ -30,18 +30,18 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/jmnedict.py b/pyglossary/plugins/jmnedict.py index fa0e05d32..3ebbeb2fa 100644 --- a/pyglossary/plugins/jmnedict.py +++ b/pyglossary/plugins/jmnedict.py @@ -23,18 +23,18 @@ from pyglossary.io_utils import nullBinaryIO __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/json_plugin.py b/pyglossary/plugins/json_plugin.py index 3d6c6c6b7..9d5c81ebe 100644 --- a/pyglossary/plugins/json_plugin.py +++ b/pyglossary/plugins/json_plugin.py @@ -17,18 +17,18 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/lingoes_ldf.py b/pyglossary/plugins/lingoes_ldf.py index beabe0d36..a48efb4e8 100644 --- a/pyglossary/plugins/lingoes_ldf.py +++ b/pyglossary/plugins/lingoes_ldf.py @@ -19,19 +19,19 @@ from pyglossary.text_utils import replaceStringTable, splitByBar __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/octopus_mdict_new/__init__.py b/pyglossary/plugins/octopus_mdict_new/__init__.py index 5194e3f1b..fd4bd7691 100644 --- a/pyglossary/plugins/octopus_mdict_new/__init__.py +++ b/pyglossary/plugins/octopus_mdict_new/__init__.py @@ -38,18 +38,18 @@ from pyglossary.text_utils import toStr __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/quickdic6.py b/pyglossary/plugins/quickdic6.py index 5b38375de..25f86c5ff 100644 --- a/pyglossary/plugins/quickdic6.py +++ b/pyglossary/plugins/quickdic6.py @@ -26,19 +26,19 @@ from pyglossary.plugin_lib import mutf8 __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True @@ -548,7 +548,7 @@ def from_path(cls: "type[QuickDic]", path_str: str) -> "QuickDic": @classmethod def from_fp(cls: "type[QuickDic]", fp: IO[bytes]) -> "QuickDic": version = read_int(fp) - created = dt.datetime.fromtimestamp(float(read_long(fp)) / 1000.0) # noqa: DTZ006 + created = dt.datetime.fromtimestamp(float(read_long(fp)) / 1000.0) # noqa: DTZ006 name = read_string(fp) sources = read_list(fp, read_entry_source) pairs = read_list(fp, read_entry_pairs) diff --git a/pyglossary/plugins/sql.py b/pyglossary/plugins/sql.py index 6d199ab98..11ba5a112 100644 --- a/pyglossary/plugins/sql.py +++ b/pyglossary/plugins/sql.py @@ -17,18 +17,18 @@ from pyglossary.glossary_types import EntryType, GlossaryType __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/stardict.py b/pyglossary/plugins/stardict.py index ba3051ecc..4122e3592 100644 --- a/pyglossary/plugins/stardict.py +++ b/pyglossary/plugins/stardict.py @@ -49,19 +49,19 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] diff --git a/pyglossary/plugins/stardict_textual.py b/pyglossary/plugins/stardict_textual.py index 479f30748..eecfd6019 100644 --- a/pyglossary/plugins/stardict_textual.py +++ b/pyglossary/plugins/stardict_textual.py @@ -26,19 +26,19 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/wiktextract.py b/pyglossary/plugins/wiktextract.py index 6353fee51..a3a846922 100644 --- a/pyglossary/plugins/wiktextract.py +++ b/pyglossary/plugins/wiktextract.py @@ -27,18 +27,18 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/wordnet.py b/pyglossary/plugins/wordnet.py index 5883222a3..32774ffb4 100644 --- a/pyglossary/plugins/wordnet.py +++ b/pyglossary/plugins/wordnet.py @@ -30,18 +30,18 @@ from pyglossary.option import Option __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/wordset.py b/pyglossary/plugins/wordset.py index d04c0f4d8..61df94a71 100644 --- a/pyglossary/plugins/wordset.py +++ b/pyglossary/plugins/wordset.py @@ -13,18 +13,18 @@ from pyglossary.sort_keys import lookupSortKey __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/xdxf/__init__.py b/pyglossary/plugins/xdxf/__init__.py index e71db1bfe..761bc9949 100644 --- a/pyglossary/plugins/xdxf/__init__.py +++ b/pyglossary/plugins/xdxf/__init__.py @@ -45,18 +45,18 @@ from pyglossary.text_utils import toStr __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/xdxf_lax.py b/pyglossary/plugins/xdxf_lax.py index f975edcbd..bdee4826d 100644 --- a/pyglossary/plugins/xdxf_lax.py +++ b/pyglossary/plugins/xdxf_lax.py @@ -47,18 +47,18 @@ from pyglossary.xdxf.xsl_transform import XslXdxfTransformer __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/yomichan.py b/pyglossary/plugins/yomichan.py index 54c741729..643f70b20 100644 --- a/pyglossary/plugins/yomichan.py +++ b/pyglossary/plugins/yomichan.py @@ -15,18 +15,18 @@ ) __all__ = [ - "enable", - "lname", - "format", + "Writer", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Writer", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/plugins/zimfile.py b/pyglossary/plugins/zimfile.py index e1b559271..3cb75d1ea 100644 --- a/pyglossary/plugins/zimfile.py +++ b/pyglossary/plugins/zimfile.py @@ -13,18 +13,18 @@ from pyglossary.glossary_types import EntryType, GlossaryType __all__ = [ - "enable", - "lname", - "format", + "Reader", "description", - "extensions", + "enable", "extensionCreate", - "singleFile", + "extensions", + "format", "kind", - "wiki", - "website", + "lname", "optionsProp", - "Reader", + "singleFile", + "website", + "wiki", ] enable = True diff --git a/pyglossary/slob.py b/pyglossary/slob.py index cefc9fcc7..804da9873 100644 --- a/pyglossary/slob.py +++ b/pyglossary/slob.py @@ -60,6 +60,7 @@ UTF8 = "utf-8" MAGIC = b"!-1SLOB\x1F" + class Compression(NamedTuple): compress: Callable[..., bytes] # first arg: bytes decompress: Callable[[bytes], bytes] @@ -815,7 +816,7 @@ def __init__( elif isinstance(count_or_spec, int): count = count_or_spec else: - raise TypeError("invalid {count_or_spec = }") + raise TypeError(f"invalid {count_or_spec = }") self._count: int = count self.pos_offset = reader.tell() self.pos_spec = pos_spec diff --git a/pyglossary/sort_keys.py b/pyglossary/sort_keys.py index 0d1ab628a..d451f2f72 100644 --- a/pyglossary/sort_keys.py +++ b/pyglossary/sort_keys.py @@ -36,6 +36,7 @@ defaultSortKeyName = "headword_lower" + class NamedSortKey(NamedTuple): name: str desc: str diff --git a/pyglossary/sq_entry_list.py b/pyglossary/sq_entry_list.py index 2a3e35954..897f1aeec 100644 --- a/pyglossary/sq_entry_list.py +++ b/pyglossary/sq_entry_list.py @@ -34,7 +34,6 @@ # typing.Self is new in Python 3.11. - __all__ = ["SqEntryList"] log = logging.getLogger("pyglossary") diff --git a/pyglossary/text_utils_extra.py b/pyglossary/text_utils_extra.py index a094bc66e..624c476d4 100644 --- a/pyglossary/text_utils_extra.py +++ b/pyglossary/text_utils_extra.py @@ -3,11 +3,12 @@ b_pattern_bar_us = re.compile(r"((? bytes: r"""Unscapes vertical bar (\|).""" # str.replace is probably faster than re.sub diff --git a/pyproject.toml b/pyproject.toml index 2b8bb75e4..ce73f4ac0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,7 +126,7 @@ lint.fixable = [ "SIM108", # Use ternary operator {contents} instead of if-else-block "C408", # Unnecessary `dict` call (rewrite as a literal) "F401", - # "E", "F", "W", + "E", "F", "W", "RET", "I", "COM", diff --git a/tests/text_utils_extra_test.py b/tests/text_utils_extra_test.py index 4cbe0be61..24ddda606 100644 --- a/tests/text_utils_extra_test.py +++ b/tests/text_utils_extra_test.py @@ -27,7 +27,6 @@ def test_formatHMS(self): self.assertEqual(f(123, 5, 7), "123:05:07") self.assertEqual(f(123, 59, 59), "123:59:59") - def test_unescapeBarBytes(self): f = unescapeBarBytes self.assertEqual(b"", f(b"")) From 120ddbb39fdbfba72357f23bb1a3ff356c20c126 Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Thu, 7 Mar 2024 07:09:00 +0330 Subject: [PATCH 2/2] Update ruff.yml --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 36672fd1c..9659cc45a 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -21,7 +21,7 @@ jobs: ls -l - name: Download ruff run: | - wget -c https://github.com/astral-sh/ruff/releases/download/v0.2.2/ruff-0.2.2-x86_64-unknown-linux-gnu.tar.gz + wget -c https://github.com/astral-sh/ruff/releases/download/v0.3.0/ruff-0.3.0-x86_64-unknown-linux-gnu.tar.gz tar -xzf ruff-*.tar.gz ls -l ruff chmod a+x ruff