diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a5f63e1f7..0fe7eb186 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: "Test" on: push: - branches: ["master", "dev", "github-action"] + branches: ["master", "dev", "github-action", "python3.9"] pull_request: schedule: - cron: "33 1 * * 3" @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ubuntu-latest steps: diff --git a/pyglossary/entry.py b/pyglossary/entry.py index 381f3f4e3..1cf626c1e 100644 --- a/pyglossary/entry.py +++ b/pyglossary/entry.py @@ -224,7 +224,7 @@ def __init__( "x": xdxf. """ # memory optimization: - if isinstance(word, list | tuple): + if isinstance(word, (list, tuple)): if len(word) == 1: word = word[0] elif not isinstance(word, str): diff --git a/pyglossary/glossary_v2.py b/pyglossary/glossary_v2.py index cfa9ecd83..2377d9db1 100644 --- a/pyglossary/glossary_v2.py +++ b/pyglossary/glossary_v2.py @@ -96,7 +96,7 @@ # ] -@dataclass(slots=True, frozen=True) +@dataclass(frozen=True) class ConvertArgs: inputFilename: str inputFormat: str = "" diff --git a/pyglossary/json_utils.py b/pyglossary/json_utils.py index 318edb9e8..343d9cd7f 100644 --- a/pyglossary/json_utils.py +++ b/pyglossary/json_utils.py @@ -6,9 +6,10 @@ if TYPE_CHECKING: from typing import AnyStr, TypeAlias -__all__ = ["dataToPrettyJson", "jsonToData"] + JsonEncodable: TypeAlias = dict | list + -JsonEncodable: TypeAlias = dict | list +__all__ = ["dataToPrettyJson", "jsonToData"] def dataToPrettyJson( diff --git a/pyglossary/plugins/appledict_bin/appledict_properties.py b/pyglossary/plugins/appledict_bin/appledict_properties.py index eefead903..af16e5df3 100644 --- a/pyglossary/plugins/appledict_bin/appledict_properties.py +++ b/pyglossary/plugins/appledict_bin/appledict_properties.py @@ -20,7 +20,7 @@ __all__ = ["AppleDictProperties", "from_metadata"] -@dataclass(slots=True, frozen=True) +@dataclass(frozen=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 2873d5c29..2de958efd 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(slots=True, frozen=True) +@dataclass(frozen=True) class BabylonLanguage: """ diff --git a/pyglossary/plugins/freedict/reader.py b/pyglossary/plugins/freedict/reader.py index 3dd0806df..65b58e69d 100644 --- a/pyglossary/plugins/freedict/reader.py +++ b/pyglossary/plugins/freedict/reader.py @@ -33,7 +33,7 @@ NAMESPACE = {None: "http://www.tei-c.org/ns/1.0"} -@dataclass(slots=True) +@dataclass class ParsedSense: transCits: list[Element] defs: list[Element] diff --git a/pyglossary/sort_keys.py b/pyglossary/sort_keys.py index 70860f3e8..767faa09a 100644 --- a/pyglossary/sort_keys.py +++ b/pyglossary/sort_keys.py @@ -48,7 +48,7 @@ class NamedSortKey(NamedTuple): sqlite: SQLiteSortKeyMakerType | None -@dataclass(slots=True) # not frozen because of mod +@dataclass # not frozen because of mod class LocaleNamedSortKey: name: str desc: str diff --git a/pyglossary/ui/main.py b/pyglossary/ui/main.py index bc411a5ac..9a255056c 100644 --- a/pyglossary/ui/main.py +++ b/pyglossary/ui/main.py @@ -101,7 +101,7 @@ def validateLangStr(st: str) -> str | None: ) -@dataclass(slots=True, frozen=True) +@dataclass(frozen=True) class MainPrepareResult: args: argparse.Namespace uiType: str diff --git a/pyglossary/xdxf/transform.py b/pyglossary/xdxf/transform.py index 0bbf59575..9b73bf0fb 100644 --- a/pyglossary/xdxf/transform.py +++ b/pyglossary/xdxf/transform.py @@ -426,7 +426,7 @@ def writeChildrenOf( for child in children: if sep and prev is not None and self.shouldAddSep(child, prev): hf.write(sep) - if isinstance(child, bytes | tuple): + if isinstance(child, (bytes, tuple)): log.warning(f"unexpected {child=}") continue self.writeChild(hf, child, elem, prev, stringSep=stringSep) diff --git a/pyproject.toml b/pyproject.toml index 40ba6553d..0bc6f0a83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ exclude = ["pyglossary/plugin_lib/ripemd128.py"] [tool.ruff] line-length = 88 -target-version = "py310" +target-version = "py39" # Exclude a variety of commonly ignored directories. exclude = [ diff --git a/tests/entry_test.py b/tests/entry_test.py index 8a4302480..84c7c657d 100644 --- a/tests/entry_test.py +++ b/tests/entry_test.py @@ -12,6 +12,8 @@ class TestEntryBasic(unittest.TestCase): def test_exc_1(self): + if sys.version_info < (3, 10): + return try: Entry(b"word", "defi") except TypeError as e: @@ -23,6 +25,8 @@ def test_exc_2(self): Entry(("word",), "defi") def test_exc_3(self): + if sys.version_info < (3, 10): + return try: Entry("word", b"defi") except TypeError as e: @@ -31,6 +35,8 @@ def test_exc_3(self): self.fail("must raise TypeError") def test_exc_4(self): + if sys.version_info < (3, 10): + return try: Entry("word", ("defi",)) except TypeError as e: