diff --git a/.github/workflows/snippets.yaml b/.github/workflows/snippets.yaml index 6774896..cc6b001 100644 --- a/.github/workflows/snippets.yaml +++ b/.github/workflows/snippets.yaml @@ -39,6 +39,10 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - name: Setup Python + uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: "3.15" - name: Test the snippet checker run: python3 -m unittest discover -s scripts -p 'test_*.py' - name: Compare the guides with examples/ diff --git a/scripts/snippets.py b/scripts/snippets.py index 31328b0..4c65636 100755 --- a/scripts/snippets.py +++ b/scripts/snippets.py @@ -102,7 +102,7 @@ def source(path: str, region: str | None) -> tuple[str | None, str]: file = ROOT / path if not file.is_file(): return None, f"file not found: {path}" - text = file.read_text(encoding="utf-8") + text = file.read_text() if region is None: return text, "" body = region_text(text, region) @@ -123,7 +123,7 @@ def fence_end(lines: list[str], start: int, fence: str) -> int: def process(page: Path, write: bool, shown: set[str]) -> list[str]: """Check or rewrite one page. Return its problems.""" rel = page.relative_to(ROOT).as_posix() - lines = page.read_text(encoding="utf-8").splitlines() + lines = page.read_text().splitlines() out: list[str] = [] problems: list[str] = [] i = 0 @@ -174,7 +174,7 @@ def process(page: Path, write: bool, shown: set[str]) -> list[str]: out.append(CLOSE) i = close + 1 if write: - page.write_text("\n".join(out) + "\n", encoding="utf-8") + page.write_text("\n".join(out) + "\n") return problems diff --git a/tests/sink.py b/tests/sink.py index 2443ef0..fe2cd6c 100755 --- a/tests/sink.py +++ b/tests/sink.py @@ -16,7 +16,7 @@ def do_POST(self) -> None: try: item = json.loads(body) except ValueError: - item = body.decode("utf-8", "replace") + item = body.decode(errors="replace") with lock: received.append(item) self.send_response(204)