Skip to content

Commit 84b2aa2

Browse files
committed
Bump min python to 3.10
1 parent 1c7b112 commit 84b2aa2

6 files changed

Lines changed: 23 additions & 42 deletions

File tree

action/check-encoding.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def main() -> int:
9090
if iconv_ok(batch, encoding):
9191
continue
9292
# The group failed somewhere; find the offending files.
93-
bad.extend(path for (path, _), blob in zip(items, split_blobs(batch)) if not iconv_ok(blob, encoding))
93+
bad.extend(
94+
path for (path, _), blob in zip(items, split_blobs(batch), strict=True) if not iconv_ok(blob, encoding)
95+
)
9496

9597
if bad:
9698
print("::error::Files with a working-tree-encoding attribute are not stored as UTF-8 in Git.")

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### WIP
44

55
- Action: now fails the run if any file with a `working-tree-encoding` gitattribute is not stored as UTF-8 in Git. Files uploaded through the GitHub web UI or contents API bypass Git's encoding filter and commit raw legacy bytes, which Git silently flags as `failed to encode` on checkout without failing the build. The check surfaces the affected files so they can be re-committed correctly.
6+
- Dropped support for Python 3.9 (end of life). The minimum supported version is now Python 3.10.
67

78
### 1.5.3
89

msg2po/dir2msgstr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import argparse
66
import os
77
import sys
8-
from typing import Optional
98

109
from loguru import logger
1110
from polib import POFile, pofile
@@ -29,7 +28,7 @@ def dir2msgstr(
2928
overwrite: bool = True,
3029
extension: str = "",
3130
same: bool = False,
32-
indexed_po: Optional[IndexedPO] = None,
31+
indexed_po: IndexedPO | None = None,
3332
):
3433
"""Loads translated strings from files in src_dir into po, mutating it in place."""
3534
logger.debug(f"overwrite is {overwrite}")

msg2po/transfile.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66
import unicodedata
77
from dataclasses import dataclass
8-
from typing import Optional
98

109
from loguru import logger
1110

@@ -20,9 +19,9 @@
2019
class TRANSEntry:
2120
index: str
2221
value: str
23-
context: Optional[str] = None
24-
female: Optional[str] = None
25-
comment: Optional[str] = None
22+
context: str | None = None
23+
female: str | None = None
24+
comment: str | None = None
2625

2726

2827
def _load_lines(filepath: str, pattern: str, dotall: bool, encoding: str) -> list[tuple[str, ...]]:
@@ -41,7 +40,7 @@ def _load_lines(filepath: str, pattern: str, dotall: bool, encoding: str) -> lis
4140
return re.findall(pattern, text)
4241

4342

44-
def _load_female_lines(filepath: str, fformat: FileFormat, encoding: str) -> Optional[list[tuple[str, ...]]]:
43+
def _load_female_lines(filepath: str, fformat: FileFormat, encoding: str) -> list[tuple[str, ...]] | None:
4544
"""Load separate female file lines if the format uses separate female files.
4645
Returns None if no female file exists or format uses inline female."""
4746
if fformat["line_format"]["female"] != "separate":
@@ -64,8 +63,8 @@ def _parse_entries(
6463
fext: str,
6564
filepath: str,
6665
is_source: bool,
67-
comment: Optional[str],
68-
female_lines: Optional[list[tuple[str, ...]]],
66+
comment: str | None,
67+
female_lines: list[tuple[str, ...]] | None,
6968
) -> list[TRANSEntry]:
7069
"""Parse regex-matched lines into TRANSEntry objects.
7170
Validates forbidden characters, duplicate indices, and '000' index."""
@@ -93,14 +92,14 @@ def _parse_entries(
9392
entry_comment = EMPTY_COMMENT
9493

9594
# context
96-
context: Optional[str] = None
95+
context: str | None = None
9796
if "context" in fformat:
9897
context = line[fformat["context"]]
9998
if context == "":
10099
context = None
101100

102101
# inline female (format has female index in regex, e.g. TRA)
103-
female: Optional[str] = None
102+
female: str | None = None
104103
if "female" in fformat:
105104
female = str(line[fformat["female"]])
106105
if female == "":
@@ -135,7 +134,7 @@ class TRANSFile:
135134
This is because PO gettext format doesn't tolerate empty msgids.
136135
"""
137136

138-
def __init__(self, filepath: str, is_source: bool = False, encoding: Optional[str] = None):
137+
def __init__(self, filepath: str, is_source: bool = False, encoding: str | None = None):
139138
if encoding is None:
140139
encoding = CONFIG.encoding
141140
self.encoding = encoding
@@ -159,7 +158,7 @@ def __init__(self, filepath: str, is_source: bool = False, encoding: Optional[st
159158
)
160159

161160

162-
def is_indexed(txt_filename: str, encoding: Optional[str] = None) -> bool:
161+
def is_indexed(txt_filename: str, encoding: str | None = None) -> bool:
163162
"""Check if a TXT file is fully indexed (all non-empty lines match index:value pattern)."""
164163
if encoding is None:
165164
encoding = CONFIG.encoding

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "A set of helper tools to convert Fallout 1/2 MSG and WeiDU TRA in
55
authors = [{ name = "BGforge", email = "dev@bgforge.net" }]
66
keywords = ["Fallout", "Fallout 2", "Baldur's Gate", "Infinity Engine", "WeiDU"]
77
readme = "README.md"
8-
requires-python = ">=3.9"
8+
requires-python = ">=3.10"
99
dependencies = [
1010
"natsort>=8.4",
1111
"polib>=1.1.1",
@@ -32,7 +32,7 @@ Repository = "https://github.com/BGforgeNet/msg2po"
3232

3333
[dependency-groups]
3434
dev = [
35-
"pytest>=7.4,<9",
35+
"pytest>=9.0.3,<10",
3636
"ruff>=0.15",
3737
"ty>=0.0.1a8",
3838
"vulture>=2.14",

uv.lock

Lines changed: 6 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)