diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 88c0c7c..9ec1f20 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,7 @@ on: [push, pull_request, workflow_dispatch] env: FORCE_COLOR: 1 + PIP_DISABLE_PIP_VERSION_CHECK: 1 permissions: contents: read @@ -17,4 +18,20 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.x" + cache: pip - uses: pre-commit/action@v3.0.1 + + mypy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + cache: pip + - name: Install dependencies + run: | + python3 -m pip install -U tox + - name: Mypy + run: tox -e mypy diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb15489..eded593 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,17 +11,12 @@ env: jobs: test: - runs-on: "${{ matrix.os }}-${{ matrix.os-version || 'latest' }}" + runs-on: "${{ matrix.os }}-latest" strategy: fail-fast: false matrix: python-version: ["pypy3.10", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] os: [Windows, macOS, Ubuntu] - # Python 3.8 and 3.9 are on macos-13 but not macos-latest (macos-14-arm64) - # https://github.com/actions/setup-python/issues/696#issuecomment-1637587760 - include: - - { python-version: "3.8", os: "macOS", os-version: "13" } - - { python-version: "3.9", os: "macOS", os-version: "13" } steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 2dc53ca..efe4d34 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ + +# hatch-vcs +src/*/_version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e564f7..0ff6293 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,14 +35,6 @@ repos: hooks: - id: actionlint - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 - hooks: - - id: mypy - args: [--strict, --pretty, --show-error-codes] - additional_dependencies: - [platformdirs, pytest, python-slugify, rapidfuzz, types-freezegun, urllib3] - - repo: https://github.com/tox-dev/pyproject-fmt rev: 2.2.1 hooks: diff --git a/pyproject.toml b/pyproject.toml index 5cd99c2..604072e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,9 @@ scripts.pep = "pepotron.cli:main" [tool.hatch] version.source = "vcs" +[tool.hatch.build.hooks.vcs] +version-file = "src/pepotron/_version.py" + [tool.hatch.version.raw-options] local_scheme = "no-local-version" diff --git a/src/pepotron/__init__.py b/src/pepotron/__init__.py index a026683..21ddb29 100644 --- a/src/pepotron/__init__.py +++ b/src/pepotron/__init__.py @@ -4,14 +4,13 @@ from __future__ import annotations -import importlib.metadata import logging from pathlib import Path from typing import Any -from . import _cache +from . import _cache, _version -__version__ = importlib.metadata.version(__name__) +__version__ = _version.__version__ BASE_URL = "https://peps.python.org" JSON_PATH = "/api/peps.json" @@ -120,7 +119,7 @@ def pairwise(iterable): # type: ignore[no-redef,no-untyped-def] def _get_github_prs() -> list[Any]: - from ghapi.all import GhApi # type: ignore[import-not-found] + from ghapi.all import GhApi # type: ignore[import-untyped] api = GhApi(owner="python", repo="peps", authenticate=False) return api.pulls.list(per_page=100) # type: ignore[no-any-return] diff --git a/tox.ini b/tox.ini index 5334ace..1f22eb3 100644 --- a/tox.ini +++ b/tox.ini @@ -41,3 +41,15 @@ pass_env = PRE_COMMIT_COLOR commands = pre-commit run --all-files --show-diff-on-failure + +[testenv:mypy] +deps = + mypy==1.11.2 + platformdirs + pytest + python-slugify + rapidfuzz + types-freezegun + urllib3 +commands = + mypy --strict --pretty --show-error-codes . {posargs}