From b518d74c1f05690af5372d5ca376260c19503d4a Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Tue, 11 Apr 2023 18:31:13 +0200 Subject: [PATCH 1/6] Require Python 3.8+ --- .github/workflows/main.yml | 6 +++--- pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee7bc07..45bcc5c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 @@ -71,7 +71,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: "3.9" - name: Set Poetry cache uses: actions/cache@v2 id: poetry-cache @@ -101,7 +101,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: "3.9" - name: Check release id: check_release run: | diff --git a/pyproject.toml b/pyproject.toml index b50d25c..c2ab60a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ "Issue Tracker" = "https://github.com/pelican-plugins/pandoc-reader/issues" [tool.poetry.dependencies] -python = ">=3.6.2,<4.0" +python = ">=3.8.1,<4.0" pelican = ">=4.5" markdown = {version = "<=3.3.4", optional = true} markdown-word-count = "^0.0.1" From 71363c1313f9d787af09eb8b9d2aebad14391e37 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Tue, 11 Apr 2023 18:31:23 +0200 Subject: [PATCH 2/6] Update linter dependency versions --- .pre-commit-config.yaml | 4 ++-- pyproject.toml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11480f3..753aec9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.3.0 hooks: - id: black @@ -29,6 +29,6 @@ repos: language_version: python3 - repo: https://github.com/PyCQA/isort - rev: 5.11.4 + rev: 5.12.0 hooks: - id: isort diff --git a/pyproject.toml b/pyproject.toml index c2ab60a..2b06aa5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,11 +37,11 @@ beautifulsoup4 = "^4.9.3" "ruamel.yaml" = "^0.17.21" [tool.poetry.dev-dependencies] -black = {version = "*", allow-prereleases = true} +black = "^23" flake8 = "^4.0.1" flake8-black = "^0.2.0" -invoke = "^1.3" -isort = "^5.4" +invoke = "^2.0" +isort = "^5.12.0" livereload = "^2.6" markdown = "<=3.3.4" pytest = "^6.0" From 32760b4bc51d9a2bdffd48e54d1f5a80917c1b83 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Tue, 11 Apr 2023 18:42:41 +0200 Subject: [PATCH 3/6] Add pyupgrade & unimport hooks to pre-commit config --- .pre-commit-config.yaml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 753aec9..d62c83b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,7 @@ --- +ci: + autoupdate_schedule: quarterly + # See https://pre-commit.com/hooks.html for info on hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -7,6 +10,7 @@ repos: - id: check-added-large-files - id: check-ast - id: check-case-conflict + - id: check-docstring-first - id: check-merge-conflict - id: check-toml - id: check-yaml @@ -26,9 +30,20 @@ repos: hooks: - id: flake8 args: [--max-line-length=88] - language_version: python3 - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort + + - repo: https://github.com/asottile/pyupgrade + rev: v3.8.0 + hooks: + - id: pyupgrade + args: [--py38-plus] + + - repo: https://github.com/hakancelikdev/unimport + rev: 0.16.0 + hooks: + - id: unimport + args: [--remove, --include-star-import] From cc265483bbb31090611b9d45e9208fbc0fdd29fe Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Tue, 11 Apr 2023 18:43:44 +0200 Subject: [PATCH 4/6] Enhance GitHub Actions CI workflow --- .github/workflows/main.yml | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45bcc5c..29ec4a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,51 +63,54 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Validate links in Markdown files uses: JustinBeckwith/linkinator-action@v1 with: retry: true + - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.9" + - name: Set Poetry cache uses: actions/cache@v2 id: poetry-cache with: path: ~/.cache/pypoetry/virtualenvs key: poetry-${{ hashFiles('**/poetry.lock') }} - - name: Upgrade Pip - run: python -m pip install --upgrade pip + - name: Install Poetry run: python -m pip install poetry + - name: Install dependencies - run: | - poetry run pip install --upgrade pip - poetry install - - name: Run linters - run: poetry run invoke lint + run: poetry install --no-interaction + - name: Run linters + run: poetry run invoke lint --diff deploy: name: Deploy needs: [test, lint] runs-on: ubuntu-latest - if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }} + if: github.ref=='refs/heads/main' && github.event_name!='pull_request' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.9" + - name: Check release id: check_release run: | python -m pip install --upgrade pip - python -m pip install poetry githubrelease httpx==0.16.1 autopub - echo "##[set-output name=release;]$(autopub check)" + python -m pip install poetry githubrelease httpx==0.18.2 autopub + echo "release=$(autopub check)" >> $GITHUB_OUTPUT - name: Publish if: ${{ steps.check_release.outputs.release=='' }} env: From 09761e840887b3921e07281c72a2fb2ffbedb479 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Tue, 11 Apr 2023 18:44:55 +0200 Subject: [PATCH 5/6] Fix build status badge Resolves: https://github.com/badges/shields/issues/8671 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3175968..985cb82 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Pandoc Reader: A Plugin for Pelican =================================== -[![Build Status](https://img.shields.io/github/workflow/status/pelican-plugins/pandoc-reader/build)](https://github.com/pelican-plugins/pandoc-reader/actions) +[![Build Status](https://img.shields.io/github/actions/workflow/status/pelican-plugins/pandoc-reader/main.yml?branch=main)](https://github.com/pelican-plugins/pandoc-reader/actions) [![PyPI Version](https://img.shields.io/pypi/v/pelican-pandoc-reader)](https://pypi.org/project/pelican-pandoc-reader/) ![License](https://img.shields.io/pypi/l/pelican-pandoc-reader?color=blue) From 45e584f56d1c55e9a56b17bcd48a6540d4aff4a9 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Tue, 11 Apr 2023 18:47:00 +0200 Subject: [PATCH 6/6] Update code for Python 3.6+ --- .../plugins/pandoc_reader/pandoc_reader.py | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/pelican/plugins/pandoc_reader/pandoc_reader.py b/pelican/plugins/pandoc_reader/pandoc_reader.py index 877c48f..61f90f0 100644 --- a/pelican/plugins/pandoc_reader/pandoc_reader.py +++ b/pelican/plugins/pandoc_reader/pandoc_reader.py @@ -110,7 +110,7 @@ def _create_html(self, source_path, content, pandoc_executable): # Find and add bibliography if citations are specified if citations: for bib_file in self._find_bibs(source_path): - pandoc_cmd.append("--bibliography={0}".format(bib_file)) + pandoc_cmd.append(f"--bibliography={bib_file}") # Create HTML content using pandoc-reader-default.html template output = self._run_pandoc(pandoc_cmd, content) @@ -166,7 +166,7 @@ def _check_defaults(self, defaults_files): # Get the data in all defaults files as a string defaults_data = "" for defaults_file in defaults_files: - with open(defaults_file, "r") as file_handle: + with open(defaults_file) as file_handle: for line in file_handle.readlines(): defaults_data += line @@ -216,7 +216,7 @@ def _calculate_reading_time(self, content): reading_time = math.ceil(float(wordcount) / float(reading_speed)) if reading_time == 1: time_unit = "minute" - reading_time = "{} {}".format(str(reading_time), time_unit) + reading_time = f"{str(reading_time)} {time_unit}" except ValueError as words_per_minute_nan: raise ValueError( "READING_SPEED setting must be a number." @@ -307,7 +307,7 @@ def _construct_pandoc_command( pandoc_cmd.extend(arguments) else: for defaults_file in defaults_files: - pandoc_cmd.append("--defaults={0}".format(defaults_file)) + pandoc_cmd.append(f"--defaults={defaults_file}") return pandoc_cmd @staticmethod @@ -398,7 +398,7 @@ def _check_arguments(arguments): """Check to see that only supported arguments have been passed.""" for arg in arguments: if arg in UNSUPPORTED_ARGUMENTS: - raise ValueError("Argument {0} is not supported.".format(arg)) + raise ValueError(f"Argument {arg} is not supported.") @staticmethod def _check_if_unsupported_settings(defaults): @@ -406,7 +406,7 @@ def _check_if_unsupported_settings(defaults): for arg in UNSUPPORTED_ARGUMENTS: arg = arg[2:] if defaults.get(arg, ""): - raise ValueError("The default {} should be set to false.".format(arg)) + raise ValueError(f"The default {arg} should be set to false.") @staticmethod def _check_input_format(defaults): @@ -422,10 +422,8 @@ def _check_input_format(defaults): # Case where both reader and from are specified which is not supported if reader_input and from_input: raise ValueError( - ( - "Specifying both from and reader is not supported." - " Please specify just one." - ) + "Specifying both from and reader is not supported." + " Please specify just one." ) if reader_input or from_input: @@ -450,10 +448,8 @@ def _check_output_format(defaults): # Case where both writer and to are specified which is not supported if writer_output and to_output: raise ValueError( - ( - "Specifying both to and writer is not supported." - " Please specify just one." - ) + "Specifying both to and writer is not supported." + " Please specify just one." ) # Case where neither writer nor to value is set to html @@ -462,9 +458,7 @@ def _check_output_format(defaults): and to_output not in VALID_OUTPUT_FORMATS ): output_formats = " or ".join(VALID_OUTPUT_FORMATS) - raise ValueError( - "Output format type must be either {}.".format(output_formats) - ) + raise ValueError(f"Output format type must be either {output_formats}.") def add_reader(readers):