From 2c72fa9b77d3d42517d051a665b402b48a40019d Mon Sep 17 00:00:00 2001 From: fliiiix Date: Tue, 8 Oct 2024 11:25:35 +0200 Subject: [PATCH 1/3] Support for Python 3.13 --- .github/workflows/main.yml | 6 +++--- pyproject.toml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e6a1227..991e4a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python 3.12 + - name: Set up Python 3.13 uses: actions/setup-python@v4 with: - python-version: 3.12 + python-version: 3.13 - name: Setup and install tools run: | python -m pip install --upgrade black flake8 @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.12] + python-version: [3.8, 3.13] runs-on: ubuntu-latest steps: diff --git a/pyproject.toml b/pyproject.toml index 632a561..f5d493e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", From fa92cceef5cd4bc04e80463161b6a0b1ba3457ac Mon Sep 17 00:00:00 2001 From: fliiiix Date: Tue, 8 Oct 2024 11:40:20 +0200 Subject: [PATCH 2/3] Upgrade to ruff for lint and format --- .github/workflows/main.yml | 10 +++++----- pandoc_plantuml_filter.py | 7 +++---- pyproject.toml | 5 +++++ tests/test_integration.py | 7 +++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 991e4a1..19332b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,11 +13,11 @@ jobs: python-version: 3.13 - name: Setup and install tools run: | - python -m pip install --upgrade black flake8 - - name: black format check - run: python -m black --check --line-length 120 pandoc_plantuml_filter.py tests - - name: flake8 format check - run: python -m flake8 --max-line-length 120 pandoc_plantuml_filter.py tests + python -m pip install --upgrade ruff + - name: format check + run: python -m ruff format --check + - name: lint check + run: python -m ruff check test: strategy: fail-fast: false diff --git a/pandoc_plantuml_filter.py b/pandoc_plantuml_filter.py index 113bc9c..92b9558 100755 --- a/pandoc_plantuml_filter.py +++ b/pandoc_plantuml_filter.py @@ -7,11 +7,10 @@ """ import os -import sys import subprocess +import sys -from pandocfilters import toJSONFilter, Para, Image -from pandocfilters import get_filename4code, get_caption, get_extension +from pandocfilters import Image, Para, get_caption, get_extension, get_filename4code, toJSONFilter PLANTUML_BIN = os.environ.get("PLANTUML_BIN", "plantuml") @@ -66,7 +65,7 @@ def plantuml(key, value, format_, meta): with open(src, "wb") as f: f.write(txt) - subprocess.check_call(PLANTUML_BIN.split() + ["-t" + filetype, src]) + subprocess.check_call([*PLANTUML_BIN.split(), "-t" + filetype, src]) sys.stderr.write("Created image " + dest + "\n") # Update symlink each run diff --git a/pyproject.toml b/pyproject.toml index f5d493e..ec977c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,4 +37,9 @@ dynamic = ["version"] [project.scripts] pandoc-plantuml = "pandoc_plantuml_filter:main" +[tool.ruff] +line-length = 120 +# Rule descriptions: https://docs.astral.sh/ruff/rules/ +lint.select = ["I", "E", "B", "F", "W", "N", "C4", "C90", "ARG", "PL", "RUF", "UP"] + [tool.setuptools_scm] diff --git a/tests/test_integration.py b/tests/test_integration.py index d7c8f9b..2f2e104 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1,7 +1,6 @@ import os import re import subprocess - from pathlib import Path import pytest @@ -39,7 +38,7 @@ def test_digrams(tmp_path, filename, expected_content, expected_files): input_file = str(__TEST_BASE_DIR__ / f"{filename}.md") output_file = str(tmp_path / f"{filename}.tex") - cmd = subprocess.run(["pandoc", input_file, "-o", output_file, "--filter", "pandoc-plantuml"]) + cmd = subprocess.run(["pandoc", input_file, "-o", output_file, "--filter", "pandoc-plantuml"], check=False) assert cmd.returncode == 0 with open(output_file) as f: @@ -56,7 +55,7 @@ def test_filetype_param_from_meta(tmp_path): input_file = str(__TEST_BASE_DIR__ / "single-diagram-with-meta.md") output_file = str(tmp_path / "single-diagram-with-meta.tex") - cmd = subprocess.run(["pandoc", input_file, "-o", output_file, "--filter", "pandoc-plantuml"]) + cmd = subprocess.run(["pandoc", input_file, "-o", output_file, "--filter", "pandoc-plantuml"], check=False) assert cmd.returncode == 0 with open(output_file) as f: @@ -72,7 +71,7 @@ def test_filetype_metadata_is_overridden_from_cli(tmp_path): output_file = str(tmp_path / "single-diagram-with-meta.tex") args = ["--metadata=plantuml-format:jpg"] - cmd = subprocess.run(["pandoc", input_file, "-o", output_file, "--filter", "pandoc-plantuml"] + args) + cmd = subprocess.run(["pandoc", input_file, "-o", output_file, "--filter", "pandoc-plantuml", *args], check=False) assert cmd.returncode == 0 with open(output_file) as f: From cd183b863c6675a77cc3074962dfffb5f11f7368 Mon Sep 17 00:00:00 2001 From: fliiiix Date: Fri, 11 Oct 2024 08:30:51 +0200 Subject: [PATCH 3/3] Update github python action The following actions use a deprecated Node.js version and will be forced to run on node20: actions/setup-python@v4. For more info: https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 19332b5..f5bb93e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.13 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.13 - name: Setup and install tools @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Setup build and test environment