From c5188aca96b82f82a8400484cd05ddc41046c43f Mon Sep 17 00:00:00 2001 From: Roberto Prevato Date: Sun, 24 Dec 2023 17:32:34 +0100 Subject: [PATCH] Add Python 3.12 to the build matrix * Add Python 3.12 to the build matrix * Add support for running tests with Python 3.12 --- .flake8 | 3 +++ .github/workflows/build.yml | 2 +- CHANGELOG.md | 6 ++++++ mkdocs-plugins.code-workspace | 6 +++++- neoteroi/mkdocs/projects/gantt/html.py | 2 +- pyproject.toml | 15 +++++++++++---- tests/__init__.py | 17 ++++++++++++----- tests/res/__init__.py | 0 8 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 tests/res/__init__.py diff --git a/.flake8 b/.flake8 index 4dc092c..00db999 100644 --- a/.flake8 +++ b/.flake8 @@ -8,3 +8,6 @@ per-file-ignores = tests/test_timeline.py:E501 tests/test_cards.py:E501 tests/test_gantt.py:E501 +exclude = + venv + dist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 737ff14..fe96d46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, "3.10", "3.11"] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 185a627..07dd47b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2023-12-24 + +- Adds support for running tests using Python 3.12, and adds Python 3.12 to the + build matrix. Note: only tests code did not support Python 3.12 because it + used `pkg_resources`. + ## [1.0.4] - 2023-07-28 :parasol_on_ground: - Unpins the dependencies on `mkdocs` and `httpx`, to fix diff --git a/mkdocs-plugins.code-workspace b/mkdocs-plugins.code-workspace index 7f33127..52c873f 100644 --- a/mkdocs-plugins.code-workspace +++ b/mkdocs-plugins.code-workspace @@ -7,7 +7,11 @@ "settings": { "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": "file:///home/ra/projects/github/mkdocs-oad-plugin/.github/workflows/build.yml" - } + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "python.formatting.provider": "none" }, "launch": { "version": "0.2.0", diff --git a/neoteroi/mkdocs/projects/gantt/html.py b/neoteroi/mkdocs/projects/gantt/html.py index d1d4491..c4deffa 100644 --- a/neoteroi/mkdocs/projects/gantt/html.py +++ b/neoteroi/mkdocs/projects/gantt/html.py @@ -410,7 +410,7 @@ def build_event(self, parent, event: Event): { "class": "nt-timeline-dot bigger", "title": f"{event.title} {self._format_time(event.time)}", - "style": f"left: {self._calc_time_left(event.time)-4}px;" + "style": f"left: {self._calc_time_left(event.time) - 4}px;" if event.time else "", }, diff --git a/pyproject.toml b/pyproject.toml index eaf143e..177e986 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,9 +5,7 @@ build-backend = "hatchling.build" [project] name = "neoteroi-mkdocs" dynamic = ["version"] -authors = [ - { name = "Roberto Prevato", email = "roberto.prevato@gmail.com" }, -] +authors = [{ name = "Roberto Prevato", email = "roberto.prevato@gmail.com" }] description = "Plugins for MkDocs and Python Markdown" readme = "README.md" requires-python = ">=3.7" @@ -20,9 +18,18 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Operating System :: OS Independent", ] -keywords = ["MkDocs", "OpenAPI", "Swagger", "Markdown", "plugins", "extensions", "documentation"] +keywords = [ + "MkDocs", + "OpenAPI", + "Swagger", + "Markdown", + "plugins", + "extensions", + "documentation", +] dependencies = [ "essentials-openapi", "mkdocs", diff --git a/tests/__init__.py b/tests/__init__.py index 2d1e8ed..961d489 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,13 +1,20 @@ import os import pprint -import pkg_resources +try: + from importlib.resources import files + def get_resource_file_path(file_name: str) -> str: + return str(files("tests.res") / file_name) -def get_resource_file_path(file_name: str) -> str: - return os.path.abspath( - pkg_resources.resource_filename(__name__, os.path.join(".", "res", file_name)) - ) +except ImportError: + # Python 3.8 + import pkg_resources + + def get_resource_file_path(file_name: str) -> str: + return pkg_resources.resource_filename( + __name__, os.path.join(".", "res", file_name) + ) def get_resource_file_contents(file_name: str) -> str: diff --git a/tests/res/__init__.py b/tests/res/__init__.py new file mode 100644 index 0000000..e69de29