diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index ad8e51d..b1c7cfb 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -10,14 +10,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up PDM - uses: pdm-project/setup-pdm@v2 - with: - python-version: 3.11 - enable-pep582: true - - name: - Work around requests bug https://github.com/psf/requests/issues/6437 - run: pip install --force requests==2.29.0 - - name: Install dependencies - run: | - pdm install -v + uses: pdm-project/setup-pdm@v3 + - name: Install deps + run: pdm install -G :all - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 50329ce..b7784f3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -21,18 +21,7 @@ jobs: environment: publish steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build pdm - pdm install --dev -G :all - - name: Build package - run: pdm build - - name: Publish package + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + - name: Publish package distributions to PyPI run: pdm publish - env: # Or as an environment variable - PDM_PUBLISH_PASSWORD: ${{ secrets.PDM_PUBLISH_PASSWORD }} diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 41c5663..d8e01f2 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -10,25 +10,15 @@ jobs: strategy: matrix: platform: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 - - uses: pdm-project/setup-pdm@v3 - name: Set up PDM - uses: pdm-project/setup-pdm@v2 + uses: pdm-project/setup-pdm@v3 with: python-version: ${{ matrix.python-version }} - enable-pep582: true - - name: - Work around requests bug https://github.com/psf/requests/issues/6437 - run: pip install --force requests==2.29.0 - - name: Install dependencies - run: | - pdm install -G:all - - name: Setup test suite - run: pdm run tox r -vv --notest - - name: Run test suite - run: pdm run tox r --skip-pkg-install - env: - PYTEST_ADDOPTS: "-vv --durations=10" + - name: Install deps + run: pdm install -G :all + - name: Run tests + run: pdm run pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6853405..a3723c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,17 +10,12 @@ repos: - id: blacken-docs additional_dependencies: [black] - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.14 + rev: v0.15 hooks: - id: validate-pyproject - - repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. - rev: v0.0.289 - hooks: - - id: ruff - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -35,7 +30,7 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit # Ruff version. - rev: "v0.0.290" + rev: "v0.0.292" hooks: - id: ruff # Respect `exclude` and `extend-exclude` settings. @@ -49,28 +44,28 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/hadialqattan/pycln - rev: v2.2.2 + rev: v2.3.0 hooks: - id: pycln additional_dependencies: [click<8.1] args: [--all] stages: [manual] - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 - hooks: - - id: mypy - files: pytoolconfig - additional_dependencies: [pydantic] - args: [] + # - repo: https://github.com/pre-commit/mirrors-mypy + # rev: v1.6.0 + # hooks: + # - id: mypy + # files: pytoolconfig + # additional_dependencies: [pydantic] + # args: [] - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.5 + rev: v0.9.0.6 hooks: - id: shellcheck diff --git a/pyproject.toml b/pyproject.toml index 3b5af6b..3ef6960 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,9 @@ dynamic = ["version"] description = 'Python tool configuration' license = { text = 'LGPL-3.0-or-later' } dependencies = [ - "tomli>=2.0.1; python_version < \"3.11\"", - "packaging>=22.0", - "typing-extensions>=4.4.0; python_version < \"3.8\"", + "tomli>=2.0.1; python_version < \"3.11\"", + "packaging>=22.0", + "typing-extensions>=4.4.0; python_version < \"3.8\"", ] requires-python = '>=3.7' readme = "README.md" @@ -23,26 +23,26 @@ validation = ['pydantic>=1.7.4'] global = ['platformdirs>=1.4.4'] doc = ['tabulate>=0.8.9', 'sphinx>=4.5.0'] gendocs = [ - 'sphinx>=4.5.0', - 'sphinx-autodoc-typehints>=1.18.1', - 'sphinx-rtd-theme>=1.0.0', - 'pytoolconfig[doc]', + 'sphinx>=4.5.0', + 'sphinx-autodoc-typehints>=1.18.1', + 'sphinx-rtd-theme>=1.0.0', + 'pytoolconfig[doc]', ] [tool.pdm] version = { source = "scm" } [tool.pdm.dev-dependencies] dev = [ - "pytest>=7.2.0", - "mypy>=0.991", - "types-tabulate>=0.9.0.2", - "tox>=4.0.8", - "tox-pdm>=0.6.0", - "types-docutils>=0.19.1.9", - "tox-gh>=1.0.0", - "pytest-emoji>=0.2.0", - "pytest-md>=0.2.0", - "pydantic>=2.3.0", + "pytest>=7.2.0", + "mypy>=0.991", + "types-tabulate>=0.9.0.2", + "tox>=4.0.8", + "tox-pdm>=0.6.0", + "types-docutils>=0.19.1.9", + "tox-gh>=1.0.0", + "pytest-emoji>=0.2.0", + "pytest-md>=0.2.0", + "pydantic>=2.3.0", ] [tool.pytoolconfig] @@ -56,18 +56,19 @@ profile = 'black' [tool.ruff] select = ["ALL"] ignore = [ - "FBT", - "D211", - "ANN101", - "ANN102", - "ANN401", - "S101", - "D212", - "D213", - "TCH001", - "TCH002", - "TCH003", - "SLF001", + "FBT", + "D211", + "ANN101", + "ANN102", + "ANN401", + "S101", + "D212", + "D213", + "TCH001", + "TCH002", + "TCH003", + "SLF001", + "FA100", ] # Always generate Python 3.7-compatible code. target-version = "py37" @@ -82,7 +83,7 @@ extend-immutable-calls = ["pytoolconfig.field"] [tool.tox] legacy_tox_ini = ''' [tox] -envlist = py37,py38, py39, py310, py311 +envlist = py37,py38, py39, py310, py311, py312 isolated_build = True [gh-actions] @@ -92,8 +93,9 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] -extras = gendocs, global +extras = doc, global groups = dev commands = pytest ''' diff --git a/src/pytoolconfig/pytoolconfig.py b/src/pytoolconfig/pytoolconfig.py index 74b0a42..08d0437 100644 --- a/src/pytoolconfig/pytoolconfig.py +++ b/src/pytoolconfig/pytoolconfig.py @@ -23,7 +23,7 @@ class PyToolConfig(Generic[DataclassT]): """Python Tool Configuration Aggregator.""" - sources: list[Source] = [] + sources: list[Source] tool: str working_directory: Path model: type[DataclassT] diff --git a/tests/test_documentation.py b/tests/test_documentation.py index e86428e..100bb64 100644 --- a/tests/test_documentation.py +++ b/tests/test_documentation.py @@ -1,7 +1,5 @@ -from __future__ import annotations - from dataclasses import dataclass -from typing import Tuple +from typing import Optional, Tuple from pytoolconfig import UniversalKey, field from pytoolconfig.documentation import _generate_table, _type_to_str @@ -15,12 +13,12 @@ class SubTool: @dataclass class NestedModel: subtool: SubTool = field(default_factory=lambda: SubTool()) - foo_other: str | None = field( + foo_other: Optional[str] = field( description="Tool One", default="no", command_line=("--foo", "-f"), ) - min_py_ver: tuple[int, int] = field( + min_py_ver: Tuple[int, int] = field( default=None, description="sauf", universal_config=UniversalKey.min_py_version, diff --git a/tests/test_pytoolconfig.py b/tests/test_pytoolconfig.py index 37f71cc..7f09232 100644 --- a/tests/test_pytoolconfig.py +++ b/tests/test_pytoolconfig.py @@ -1,9 +1,8 @@ -from __future__ import annotations - import os import sys from argparse import ArgumentParser from dataclasses import dataclass, fields +from typing import Tuple import pytest from pytoolconfig import PyToolConfig, UniversalKey, field @@ -31,7 +30,7 @@ class NestedModel: subtool: SubTool = field(default_factory=lambda: SubTool()) foo_other: str = field(description="w", default="no", command_line=("--foo", "-f")) - target: tuple[int, int] = field( + target: Tuple[int, int] = field( description="Minimum python version", default=(3, 1), universal_config=UniversalKey.min_py_version,