Skip to content

Commit

Permalink
add back compat with python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jan 2, 2025
1 parent e10bf9c commit 7ba15de
Show file tree
Hide file tree
Showing 15 changed files with 572 additions and 816 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
# ]


@dataclass(slots=True, frozen=True)
@dataclass(frozen=True)
class ConvertArgs:
inputFilename: str
inputFormat: str = ""
Expand Down
5 changes: 3 additions & 2 deletions pyglossary/json_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 0 additions & 7 deletions pyglossary/plugins/aard2_slob/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,12 @@ def __iter__(self) -> Iterator[EntryType | None]:
raise RuntimeError("iterating over a reader while it's not open")

slobObj = self._slobObj
blobSet = set()

# slob library gives duplicate blobs when iterating over slobObj
# even keeping the last id is not enough, since duplicate blobs
# are not all consecutive. so we have to keep a set of blob IDs

for blob in slobObj:
id_ = blob.identity
if id_ in blobSet:
yield None # update progressbar
continue
blobSet.add(id_)

# blob.key is str, blob.content is bytes
word = blob.key

Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/aard2_slob/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _open(self, filepath: str, namePostfix: str) -> slob.Writer:
observer=self._slobObserver,
workdir=cacheDir,
compression=self._compression,
version_info=self._version_info,
# version_info=self._version_info,
)

# "label" tag is a dictionary name shown in UI
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/appledict_bin/appledict_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/babylon_bgl/bgl_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
__all__ = ["BabylonLanguage", "languageByCode"]


@dataclass(slots=True, frozen=True)
@dataclass(frozen=True)
class BabylonLanguage:

"""
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/freedict/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading

0 comments on commit 7ba15de

Please sign in to comment.