Skip to content

Commit

Permalink
fix: add python 3.13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kai687 committed Oct 21, 2024
1 parent 81610f4 commit 6d6cc17
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 455 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up python 3.12
- name: Set up python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: 3.13
cache: pip

- name: Install dependencies
run: |
pip install -U pip pipx nox poetry-plugin-export
pip install -U pip nox poetry poetry-plugin-export
pip --version
nox --version
poetry --version
poetry self show plugins
- name: Run nox workflow
run: nox --sessions "tests" --python "3.12" coverage
run: nox --sessions "tests" --python "3.13" coverage
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
32 changes: 0 additions & 32 deletions .github/workflows/lint.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Update pip and install pipx
- name: Install dependencies
run: |
pip install -U pip nox poetry-plugin-export yamllint
pip --version
Expand All @@ -29,6 +29,5 @@ jobs:
poetry self show plugins
yamllint --version
- name: Run unit tests with nox
run: |
nox --sessions tests --python ${{ matrix.python-version }}
- name: Run workflows
run: nox --python ${{ matrix.python-version }}
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.18.0
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.1
rev: v0.7.0
hooks:
- id: ruff
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

nox.options.stop_on_first_error = True
nox.options.sessions = ["tests", "lint", "mypy", "safety"]
python_versions = ["3.8", "3.9", "3.10", "3.11", "3.12"]
python_versions = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
session_install = nox.Session.install


Expand Down Expand Up @@ -80,7 +80,7 @@ def fmt(session: nox.Session) -> None:
session.run("ruff", "format", ".")


@nox.session(python=["3.8", "3.12"])
@nox.session(python=[python_versions[0], python_versions[-1]])
def mypy(session: nox.Session) -> None:
"""Check types with Mypy."""
deps = [
Expand Down
869 changes: 475 additions & 394 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ packages = [
python = "^3.8"
sphinx = [
{ version = "<7.2", python = ">=3.8,<3.9"},
{ version = "^7.2,<7.4", python = ">=3.9,<=3.13"},
{ version = "^7.2,<7.4", python = ">=3.9,<3.11"},
{ version = "^8", python = ">=3.11,<3.14" }
]

[tool.poetry.group.dev.dependencies]
Expand All @@ -39,9 +40,9 @@ defusedxml = "0.7.1"
[tool.poetry.group.lint.dependencies]
pre-commit = [
{ version = "^3.5", python = ">=3.8,<3.9"},
{ version = "^3.6", python = ">=3.9,<=3.12"},
{ version = "^3.6", python = ">=3.9,<=3.13"},
]
ruff = ">=0.5.1,<0.6.10"
ruff = "^0.7"

[tool.coverage.paths]
source = ["src"]
Expand All @@ -66,7 +67,7 @@ warn_unused_ignores = false

[tool.ruff.lint]
select = ["E", "F", "B", "Q", "W", "I", "C90", "D", "UP", "YTT", "S", "ANN", "SIM", "N"]
ignore = ["ANN401", "S603", "D203", "D213"]
ignore = ["ANN101", "ANN401", "S603", "D203", "D213"]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"]
Expand Down
24 changes: 12 additions & 12 deletions src/sphinxawesome/codelinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
:license: MIT, see LICENSE for details
"""

from __future__ import annotations

from importlib.metadata import PackageNotFoundError, version
from io import BytesIO
from subprocess import PIPE, STDOUT, Popen
from typing import Any, Dict, Iterable, Optional, Set, Union
from typing import AbstractSet, Any, Iterable

from docutils import nodes
from sphinx.application import Sphinx
Expand Down Expand Up @@ -47,29 +49,27 @@ class CodeLinter(Builder):
epilog = __("Lint code blocks.")
allow_parallel = True

def init(self: "CodeLinter") -> None:
def init(self) -> None:
"""Initialize."""
pass

def get_outdated_docs(self: "CodeLinter") -> Union[str, Iterable[str]]:
def get_outdated_docs(self) -> str | Iterable[str]:
"""Check for outdated files.
Return an iterable of outdated output files, or a string describing what an
update will build.
"""
return self.env.found_docs # pragma: nocover
return self.env.found_docs

def get_target_uri(
self: "CodeLinter", docname: str, typ: Optional[str] = None
) -> str:
def get_target_uri(self, docname: str, typ: str | None = None) -> str:
"""Return Target URI for a document name."""
return "" # pragma: no cover
return ""

def prepare_writing(self: "CodeLinter", docnames: Set[str]) -> None:
def prepare_writing(self, docnames: AbstractSet[str]) -> None:
"""Run these steps before documents are written."""
return

def write_doc(self: "CodeLinter", docname: str, doctree: nodes.Node) -> None:
def write_doc(self, docname: str, doctree: nodes.Node) -> None:
"""Execute the builder."""
# Read the dict ``codelinter_languages`` from ``conf.py``
# it has the language as key and the tool as value.
Expand Down Expand Up @@ -107,12 +107,12 @@ def write_doc(self: "CodeLinter", docname: str, doctree: nodes.Node) -> None:
else:
logger.info(" " + darkgreen("OK"))

def finish(self: "CodeLinter") -> None:
def finish(self) -> None:
"""Finish the build process."""
pass


def setup(app: Sphinx) -> Dict[str, Any]:
def setup(app: Sphinx) -> dict[str, Any]:
"""Register this extension with Sphinx."""
app.add_builder(CodeLinter)
app.add_config_value("codelinter_languages", {}, "env")
Expand Down

0 comments on commit 6d6cc17

Please sign in to comment.