diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d51b21..39cac92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,13 +23,15 @@ jobs: strategy: matrix: platform: [ubuntu-latest] - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9", "3.10"] include: - platform: macos-latest python-version: "3.9" - platform: windows-latest python-version: "3.9" + runs-on: ${{ matrix.platform }} + steps: - uses: actions/setup-python@v2 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e8b2f7..8fb20e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,6 @@ repos: language_version: python3 - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 4.0.1 hooks: - id: flake8 diff --git a/justfile b/justfile index d8b8f7c..38e14fa 100644 --- a/justfile +++ b/justfile @@ -7,7 +7,7 @@ default: tag: @if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 1; fi - curl -H "Authorization: token `cat ~/.github-access-token`" -d '{"tag_name": "{{version}}"}' https://api.github.com/repos/nschloe/{{name}}/releases + curl -H "Authorization: token `cat ~/.github-access-token`" -d '{"tag_name": "v{{version}}"}' https://api.github.com/repos/nschloe/{{name}}/releases upload: clean @if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then exit 1; fi diff --git a/setup.cfg b/setup.cfg index fd83113..4b1be38 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pytest-codeblocks -version = 0.11.3 +version = 0.11.4 author = Nico Schlömer author_email = nico.schloemer@gmail.com description = Test code blocks in your READMEs @@ -20,19 +20,18 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 [options] package_dir = =src packages = find: install_requires = - dataclasses;python_version<"3.7" pytest >=6 -python_requires = >=3.6 +python_requires = >=3.7 [options.packages.find] where=src diff --git a/src/pytest_codeblocks/main.py b/src/pytest_codeblocks/main.py index deaa40b..fb8fdc7 100644 --- a/src/pytest_codeblocks/main.py +++ b/src/pytest_codeblocks/main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import contextlib import re import sys @@ -7,20 +9,19 @@ from dataclasses import dataclass from io import StringIO from pathlib import Path -from typing import Optional, Union @dataclass class CodeBlock: code: str lineno: int - syntax: Optional[str] = None - expected_output: Optional[str] = None + syntax: str | None = None + expected_output: str | None = None expect_exception: bool = False def extract_from_file( - f: Union[str, bytes, Path], encoding: Optional[str] = "utf-8", *args, **kwargs + f: str | bytes | Path, encoding: str | None = "utf-8", *args, **kwargs ): with open(f, encoding=encoding) as handle: return extract_from_buffer(handle, *args, **kwargs)