diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index fb6b411e..0f27497e 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -13,7 +13,7 @@ on: - docs/** - examples/** - mkdocs.yml - - setup.py + - pyproject.toml pull_request: paths: - apischema/** @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.12' - name: Install apischema run: pip install -e . - name: Install requirements @@ -66,6 +66,8 @@ jobs: ${{ runner.os }}-pip- - uses: actions/checkout@v3 - uses: actions/setup-python@v4 + with: + python-version: '3.12' - uses: actions/download-artifact@v3 with: name: benchmark_table @@ -99,6 +101,8 @@ jobs: ${{ runner.os }}-pip- - uses: actions/checkout@v3 - uses: actions/setup-python@v4 + with: + python-version: '3.12' - uses: actions/download-artifact@v3 with: name: benchmark_table @@ -120,12 +124,12 @@ jobs: git fetch origin gh-pages --depth=1 - name: Set environment variable run: | - echo "version=$(python setup.py --version | cut -d. -f-2)" >> $GITHUB_ENV - echo "revision=$(python setup.py --version | cut -d. -f3)" >> $GITHUB_ENV + echo "version=$(cat pyproject.toml | grep "version =" | cut -d' ' -f3 | cut -d'"' -f2 | cut -d. -f-2)" >> $GITHUB_ENV + echo "revision=$(cat pyproject.toml | grep "version =" | cut -d' ' -f3 | cut -d'"' -f2 | cut -d. -f3)" >> $GITHUB_ENV echo "latest=$(mike list latest -j | jq .version -r)" >> $GITHUB_ENV - name: Publish dev documentation if: github.event_name == 'push' && env.version != env.latest - run: mike deploy -p $version dev -t "$version (dev)" -u + run: mike deploy -p $version dev -t "dev" -u - name: Publish latest documentation if: github.event_name == 'release' && env.revision == '0' run: | diff --git a/README.md b/README.md index f184139e..fa5e0402 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ It requires only Python 3.8+. *PyPy3* is also fully supported. ## Why another library? -(If you wonder how this differs from the *pydantic* library, see the [dedicated section of the documentation](https://wyfo.github.io/apischema/0.18/difference_with_pydantic) — there are many differences.) +(If you wonder how this differs from the *pydantic* library, see the [dedicated section of the documentation](https://wyfo.github.io/apischema/dev/difference_with_pydantic) — there are many differences.) This library fulfills the following goals: @@ -25,11 +25,11 @@ This library fulfills the following goals: - be adaptable, provide tools to support any types (ORM, etc.); - avoid dynamic things like using raw strings for attributes name - play nicely with your IDE. -No known alternative achieves all of this, and apischema is also [(a lot) faster](https://wyfo.github.io/apischema/0.18/optimizations_and_benchmark#benchmark) than all of them. +No known alternative achieves all of this, and apischema is also [(a lot) faster](https://wyfo.github.io/apischema/dev/optimizations_and_benchmark#benchmark) than all of them. On top of that, because APIs are not only JSON, *apischema* is also a complete GraphQL library -> Actually, *apischema* is even adaptable enough to enable support of competitor libraries in a few dozens of line of code ([pydantic support example](https://wyfo.github.io/apischema/0.18/examples/pydantic_support) using [conversions feature](https://wyfo.github.io/apischema/0.18/conversions)) +> Actually, *apischema* is even adaptable enough to enable support of competitor libraries in a few dozens of line of code ([pydantic support example](https://wyfo.github.io/apischema/dev/examples/pydantic_support) using [conversions feature](https://wyfo.github.io/apischema/dev/conversions)) ## Example diff --git a/benchmark/benchmarks/pydantic.py b/benchmark/benchmarks/pydantic.py index 7a01eec1..cbf512c3 100644 --- a/benchmark/benchmarks/pydantic.py +++ b/benchmark/benchmarks/pydantic.py @@ -1,13 +1,12 @@ from datetime import datetime from typing import Optional, Type -import pydantic.generics +import pydantic from common import Benchmark, Methods, Payment, to_camel_case class CamelModel(pydantic.BaseModel): - class Config: - alias_generator = to_camel_case + model_config = pydantic.ConfigDict(alias_generator=to_camel_case) class Message(CamelModel): diff --git a/pyproject.toml b/pyproject.toml index 3b852732..4d4d2743 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "apischema" -version = "0.18.1" +version = "0.19.0" authors = [{ name = "Joseph Perez", email = "joperez@hotmail.fr" }] license = { text = "MIT" } description = "JSON (de)serialization, GraphQL and JSON schema generation using Python typing." diff --git a/scripts/generate_readme.py b/scripts/generate_readme.py index b79efe9f..5e2c7f43 100755 --- a/scripts/generate_readme.py +++ b/scripts/generate_readme.py @@ -6,18 +6,12 @@ ROOT_DIR = pathlib.Path(__file__).parent.parent README = ROOT_DIR / "README.md" INDEX = ROOT_DIR / "docs" / "index.md" -PYPROJECT = ROOT_DIR / "pyproject.toml" QUICKSTART = ROOT_DIR / "examples" / "quickstart.py" -USED_FILES = { - str(path.relative_to(ROOT_DIR)) for path in (INDEX, PYPROJECT, QUICKSTART) -} +USED_FILES = {str(path.relative_to(ROOT_DIR)) for path in (INDEX, QUICKSTART)} def main(): - version_match = re.search(r"version = \"(\d+\.\d+)", PYPROJECT.read_text()) - assert version_match is not None - version = version_match.group(1) content = INDEX.read_text() # Set title content = re.sub(r"# Overview\s*## apischema", "# apischema", content) @@ -30,7 +24,7 @@ def main(): content = content.replace( r"", "\n".join( - f"![benchmark chart](https://wyfo.github.io/apischema/{version}/" + "![benchmark chart](https://wyfo.github.io/apischema/dev/" f"benchmark_chart_{theme}#gh-{theme}-mode-only)" for theme in ("light", "dark") ), @@ -39,12 +33,12 @@ def main(): content = re.sub(r"", lambda m: m.group(1), content) # TODO remove this unused part? content = re.sub( - r"(\d+\.\d+)/benchmark_chart\.svg", f"{version}/benchmark_chart.svg", content + r"(\d+\.\d+)/benchmark_chart\.svg", "dev/benchmark_chart.svg", content ) # Rewrite links content = re.sub( r"\(([\w/]+)\.(md|svg)(#[\w-]+)?\)", - lambda m: f"(https://wyfo.github.io/apischema/{version}/{m.group(1)}" + lambda m: f"(https://wyfo.github.io/apischema/dev/{m.group(1)}" + (".svg" if m.group(2) == "svg" else "") + (m.group(3) or "") + ")",