Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Github Release/Publish PyPi
jame: Github Release/Publish PyPi

on:
push:
Expand All @@ -21,17 +21,15 @@ jobs:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/cappa
url: https://pypi.org/p/dataclass-settings
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: 1.2.2
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Build dist
run: poetry build
run: uvx --from build pyproject-build --installer uv
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
59 changes: 31 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,64 @@ jobs:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
pydantic-version: ["1.0", "2.0"]

env:
UV_CACHE_DIR: /tmp/.uv-cache
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
allow-prereleases: true

- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Restore uv cache
uses: actions/cache@v4
with:
poetry-version: 2.0.0

- name: Set up cache
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}

- name: Install dependencies
run: |
make install
pip install 'pydantic~=${{ matrix.pydantic-version }}'
uv pip install 'pydantic~=${{ matrix.pydantic-version }}'

- name: Run Linters
run: poetry run make lint
run: make lint

- name: Run tests
run: poetry run make test
run: make test

- name: Store test result artifacts
uses: actions/upload-artifact@v4
with:
path: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }}.xml

- name: Coveralls
env:
COVERALLS_FLAG_NAME: run-${{ inputs.working-directory }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
run: |
pip install tomli coveralls
coveralls --service=github
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: python=${{ matrix.python-version }}-pydantic=${{matrix.pydantic-version}}
files: coverage.xml

typos:
name: Check for typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Spell Check Repo
uses: crate-ci/typos@v1.30.0

finish:
needs:
- test
- typos
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install tomli coveralls
coveralls --service=github --finish
- name: Join
run: echo Done
28 changes: 11 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
.PHONY: install test lint format build publish

PACKAGE_VERSION = $(shell python -c 'import importlib.metadata; print(importlib.metadata.version("responsaas"))')
.PHONY: install test lint format

install:
poetry install
uv sync

test:
coverage run -m pytest src tests
coverage combine
coverage report
coverage xml
uv run coverage run -m pytest src tests
uv run coverage combine
uv run coverage report
uv run coverage xml

lint:
ruff check src tests || exit 1
mypy src tests || exit 1
ruff format --check --diff src tests || exit 1
uv run ruff check src tests || exit 1
uv run mypy src tests || exit 1
uv run ruff format --check --diff src tests || exit 1

format:
ruff check --fix src tests
ruff format src tests

readme-image:
FORCE_COLOR=true python readme.py --help | ansitoimg --title '' docs/source/_static/example.svg

uv run ruff check --fix src tests
uv run ruff format src tests
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ example: Example = load_settings(Example, nested_delimiter='_')
### Clarity

- `pydantic-settings` makes it really, really difficult to intuit what the
concrete environment varibale that's going to be loaded for a given field is
concrete environment variable that's going to be loaded for a given field is
**actually** going to be. Based on my own experience, and from perusing their
issue tracker, it seems like this is not an uncommon experience.

Expand Down Expand Up @@ -127,7 +127,7 @@ example: Example = load_settings(Example, nested_delimiter='_')

Practically, `pydantic` has the most robust system for parsing/validating a
json-like structure into the models, so it's probably to be the most flexible
anyways. But for many simple cases, particuarly those without nesting, or that
anyways. But for many simple cases, particularly those without nesting, or that
only deal in simple types (like int, float, str, etc); then dataclasses/attrs
can certainly provide a similar experience.

Expand Down
40 changes: 21 additions & 19 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
[tool.poetry]
[project]
name = "docs"
version = "0.1.0"
description = ""
authors = ["Dan Cardin <ddcardin@gmail.com>"]
authors = [{ name = "Dan Cardin", email = "ddcardin@gmail.com" }]

[tool.poetry.dependencies]
python = "^3.10"
requires-python = ">=3.10"

astroid = "^3"
dependencies = [
"astroid >= 3",
"furo >= 2024.04.27",
"linkify-it-py",
"myst-parser[linkify] >= 4.0.1",
"sphinx >= 7.4.0",
"sphinx-autoapi >= 3.6.0",
"sphinx-autobuild >= 2021.3.14",
"sphinx-autodoc-typehints >= 1.18.1",
"sphinx-copybutton",
"sphinx-pyproject >= 0.3.0",
]

furo = "^2024.04.27"
linkify-it-py = "*"
myst-parser = {version = "^4.0.1", extras = ["linkify"]}
sphinx = "^7.4.0"
sphinx-autoapi = "^3.6.0"
sphinx-autobuild = "^2021.3.14"
sphinx-autodoc-typehints = "^1.18.1"
sphinx-copybutton = "*"
sphinx-pyproject = ">=0.3.0"

[tool.poetry.dev-dependencies]
sphinx-autobuild = "*"
[tool.uv]
dev-dependencies = [
"sphinx-autobuild",
]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sphinx_pyproject import SphinxConfig

config = SphinxConfig("../../pyproject.toml", style="poetry")
config = SphinxConfig("../../pyproject.toml")

project = "Dataclass Settings"
copyright = "2023, Dan Cardin"
Expand Down
Loading
Loading