Skip to content

Commit

Permalink
Merge pull request #16 from bagel897/workflows
Browse files Browse the repository at this point in the history
update workflows and tests
  • Loading branch information
bagel897 authored Oct 14, 2023
2 parents 08b6a3b + a6a185f commit c27713e
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 98 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
17 changes: 3 additions & 14 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
22 changes: 6 additions & 16 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 13 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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

Expand Down
64 changes: 33 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand All @@ -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"
Expand All @@ -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]
Expand All @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion src/pytoolconfig/pytoolconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 3 additions & 5 deletions tests/test_documentation.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions tests/test_pytoolconfig.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c27713e

Please sign in to comment.