Skip to content

Commit

Permalink
Merge pull request #30 from timofurrer/feature/new-python
Browse files Browse the repository at this point in the history
Support for Python 3.13 and Ruff
  • Loading branch information
fliiiix authored Oct 11, 2024
2 parents f7fc950 + cd183b8 commit 49f076a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.12
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
matrix:
python-version: [3.8, 3.12]
python-version: [3.8, 3.13]

runs-on: ubuntu-latest
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
Expand Down
7 changes: 3 additions & 4 deletions pandoc_plantuml_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -36,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]
7 changes: 3 additions & 4 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import re
import subprocess

from pathlib import Path

import pytest
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 49f076a

Please sign in to comment.