Skip to content

Commit 0c379c6

Browse files
committed
require Python 3.12, fix some mypy, ruff and pylint errors
add ALL to ruff rules, fix some rules and ignore some
1 parent 7418152 commit 0c379c6

63 files changed

Lines changed: 384 additions & 317 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-deprecated.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.11"]
18+
python-version: ["3.12"]
1919

2020
runs-on: ubuntu-latest
2121
steps:

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
python-version:
19-
- 3.11
2019
- 3.12
2120
- 3.13
2221

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ So you need to select the format (with UI or `--read-format` flag).
107107

108108
## Requirements
109109

110-
PyGlossary requires **Python 3.11 or higher**, and works in practically all
110+
PyGlossary requires **Python 3.12 or higher**, and works in practically all
111111
mainstream operating systems, including *GNU/Linux*, *Windows*, *Mac OS*,
112112
*FreeBSD* and other common Unix-based operating systems.
113113

pyglossary/entry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class Entry(BaseEntry): # noqa: PLR0904
160160
xdxfPattern = re.compile("^<k>[^<>]*</k>", re.DOTALL | re.IGNORECASE)
161161
htmlPattern = re.compile(
162162
".*(?:"
163-
+ "|".join(
163+
+ "|".join( # noqa: FLY002
164164
[
165165
r"<font[ >]",
166166
r"<br\s*/?\s*>",

pyglossary/entry_base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import typing
65
import warnings
76
from abc import ABC, abstractmethod
87
from typing import TYPE_CHECKING
@@ -12,7 +11,7 @@
1211

1312
__all__ = ["BaseEntry", "MultiStr"]
1413

15-
MultiStr: typing.TypeAlias = "str | list[str]"
14+
type MultiStr = str | list[str]
1615

1716

1817
class BaseEntry(ABC): # noqa: PLR0904

pyglossary/flags.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Self
4-
5-
if TYPE_CHECKING:
6-
from typing import TypeAlias
3+
from typing import Self
74

85
__all__ = [
96
"ALWAYS",
@@ -35,4 +32,4 @@ def __new__(cls: type, name: str, desc: str) -> Self:
3532
NEVER = StrWithDesc("never", "Never")
3633

3734
# to satisfy mypy:
38-
YesNoAlwaysNever: TypeAlias = StrWithDesc
35+
type YesNoAlwaysNever = StrWithDesc

pyglossary/glossary_types.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from typing import TYPE_CHECKING, Any, Protocol
1010

1111
if TYPE_CHECKING:
12-
from typing import TypeAlias
13-
1412
from .langs import Lang
1513
from .sort_keys import NamedSortKey
1614

@@ -23,12 +21,12 @@
2321
"WriterGlossaryType",
2422
]
2523

26-
MultiStr: TypeAlias = "str | list[str]"
24+
type MultiStr = str | list[str]
2725

2826
# str(rawEntry[0]): defiFormat or ""
2927
# rawEntry[1]: b_defi
3028
# rawEntry[2:]: b_term_list
31-
RawEntryType: TypeAlias = Sequence[bytes]
29+
type RawEntryType = Sequence[bytes]
3230

3331

3432
class EntryType(Protocol): # noqa: PLR0904

pyglossary/iter_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
# from https://github.com/erikrose/more-itertools
30-
def unique_everseen(iterable: Iterable) -> Iterator:
30+
def unique_everseen[T](iterable: Iterable[T]) -> Iterator[T]:
3131
"""List unique elements, preserving order. Remember all elements ever seen."""
3232
from itertools import filterfalse
3333

pyglossary/json_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from __future__ import annotations
22

33
import json
4-
from typing import TYPE_CHECKING
4+
from typing import TYPE_CHECKING, Any
55

66
if TYPE_CHECKING:
7-
from typing import AnyStr, TypeAlias
7+
from typing import AnyStr
88

99
__all__ = ["dataToPrettyJson", "jsonToData"]
1010

11-
JsonEncodable: TypeAlias = dict | list
11+
type JsonEncodable = dict[Any, Any] | list[Any]
1212

1313

1414
def dataToPrettyJson(
@@ -24,5 +24,5 @@ def dataToPrettyJson(
2424
)
2525

2626

27-
def jsonToData(st: AnyStr) -> JsonEncodable:
27+
def jsonToData[AnyStr: (bytes, str)](st: AnyStr) -> JsonEncodable:
2828
return json.loads(st)

pyglossary/langs/writing_system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class WritingSystem(NamedTuple):
1919
name: str
2020
iso: list[tuple[int, str]] | list[tuple[int, str, str]] = []
21-
unicode: list = []
21+
unicode: list[str] = []
2222
titleTag: str = "b"
2323
direction: Literal["ltr", "rtl", "ttb"] = "ltr"
2424
comma: str = ", "

0 commit comments

Comments
 (0)