Skip to content
Merged

v2 #49

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0ec841f
feat: pydantic v2 support
khalo-sa Jul 27, 2023
21799cd
bump version to 1.1.10
khalo-sa Jul 28, 2023
630ae4d
feat: v2 - convert computed fields
khalo-sa Aug 9, 2023
787f229
bump version to 1.1.11
khalo-sa Aug 9, 2023
cdae02e
test: add test for extra config
khalo-sa Aug 9, 2023
3c3ff0a
Tweaks so v1 pydantic models are supported even if version 2.0.0+ is …
phillipdupuis Nov 10, 2024
1bf83dd
Parametrize tests for both versions of pydantic, update test results …
phillipdupuis Nov 11, 2024
833b938
Build changes: temporarily disable black linting requirement, run tes…
phillipdupuis Nov 11, 2024
205c845
Fix invalid yaml
phillipdupuis Nov 11, 2024
7088d2f
Fix invalid yaml
phillipdupuis Nov 11, 2024
060eff9
Combine tests against pydantic V1 and V2 into a single coverage report
phillipdupuis Nov 11, 2024
4ede224
Fix pip install for pydantic v1
phillipdupuis Nov 11, 2024
7ed40e3
clean up handling of v1/v2 branching
phillipdupuis Nov 11, 2024
fe5bd46
Basic ruff setup, still need to update cicd steps to remove black fully
phillipdupuis Nov 11, 2024
2006f58
V2, update setup.py -- drop support for python<3.8, add support for 3…
phillipdupuis Nov 11, 2024
5a839c7
LOTS of changes, todo - better commit msg
phillipdupuis Nov 11, 2024
6c9d5a3
Update test_script, update v1 tests to work with both pydantic<2 and …
phillipdupuis Nov 11, 2024
97a09c9
Rework the V1 logic for 'nullable' field schemas, update the tests fo…
phillipdupuis Nov 12, 2024
a1eed34
Fix typo, should be 'AssertionError' and not 'AttributeError'
phillipdupuis Nov 12, 2024
53d3098
Add 'pydantic_v1' and 'pydantic_v2' submodules, these serve as safe n…
phillipdupuis Nov 13, 2024
05a7526
Add build step for running tests against pydantic@1.8.2
phillipdupuis Nov 13, 2024
1ac8244
Update base python version from 3.8 to 3.9
phillipdupuis Nov 13, 2024
ef1b56e
Clean up logic for making fields nullable in v1, also clean up how te…
phillipdupuis Nov 21, 2024
5711c91
Start migrating to uv for project management
phillipdupuis Nov 21, 2024
e99563b
Fix github action for ruff lint
phillipdupuis Nov 21, 2024
d86452b
Fix github action for combining coverage data
phillipdupuis Nov 21, 2024
585fbca
Fix github workflow for combining coverage data from multiple test runs
phillipdupuis Nov 21, 2024
923c7ee
Exclude TYPE_CHECKING logic from coverage report
phillipdupuis Nov 21, 2024
1b82de0
Update github action for this project
phillipdupuis Nov 21, 2024
a78230a
Rewrite tests to ensure that the typescript output is identical for b…
phillipdupuis Nov 22, 2024
4b3f0ae
Make 'module' and 'output' args required
phillipdupuis Nov 22, 2024
cfd0a19
CICD: run tests using uv
phillipdupuis Nov 22, 2024
daf1835
CICD: fix the step for running tests against pydantic@1.8.2
phillipdupuis Nov 22, 2024
1bdcf49
'clean_json_schema' will now also remove the 'str' docstring, in pyda…
phillipdupuis Nov 22, 2024
5fbd3a0
Remove the '.python-version' file, it keeps causing uv to ignore the …
phillipdupuis Nov 22, 2024
46176bd
CICD: make 'test' stage require 'lint' passes, change coveralls actio…
phillipdupuis Nov 22, 2024
ad3b57d
Typo in coveralls action, '2' should be 'v2'
phillipdupuis Nov 22, 2024
168104d
CICD: modernize step for publishing to pypi, use trusted publisher wo…
phillipdupuis Nov 22, 2024
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
114 changes: 67 additions & 47 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,98 @@ on:
pull_request:
jobs:
lint:
name: Lint code with black
name: Lint code with ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v1
with:
src: ./pydantic2ts
test:
name: Run unit tests
needs: lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.8"]
python-version: ["3.9"]
include:
- os: ubuntu-latest
python-version: "3.6"
python-version: "3.8"
- os: ubuntu-latest
python-version: "3.7"
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.9"
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.10"
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.13"
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Set up Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
python-version: ${{ matrix.python-version }}
node-version: 20
- name: Install json-schema-to-typescript
run: npm i -g json-schema-to-typescript
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.5.2"
- name: Run tests against 'pydantic@latest'
run: |
npm i -g json-schema-to-typescript
- name: Install python dependencies
run: |
python -m pip install -U pip wheel pytest pytest-cov coverage
python -m pip install -U .
- name: Run tests
run: |
python -m pytest --cov=pydantic2ts
- name: Generate LCOV File
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
uv python install ${{ matrix.python-version }}
uv sync --all-extras --dev
uv run pytest --cov=pydantic2ts
- name: (ubuntu 3.9) Run tests against 'pydantic==1.8.2' and generate an LCOV file for Coveralls
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }}
run: |
coverage lcov
- name: Coveralls
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }}
uses: coverallsapp/github-action@master
uv add 'pydantic==1.8.2'
uv run pytest --cov=pydantic2ts --cov-append
uv run coverage lcov
- name: (ubuntu 3.9) Upload to Coveralls
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }}
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov
deploy:
name: Deploy to PyPi
runs-on: ubuntu-latest
build:
name: Build pydantic2ts for distribution
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
- name: Check out repo
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install -U pip wheel
- name: Build dist
run: |
python setup.py sdist bdist_wheel bdist_egg
- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.5.0
version: "0.5.2"
- name: Install python 3.9
run: uv python install 3.9
- name: Build pydantic2ts
run: uv build
- name: Store the distribution
uses: actions/upload-artifact@v4
with:
name: pydantic2ts-dist
path: dist/
publish-to-pypi:
name: Publish pydantic2ts to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pydantic-to-typescript
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
user: __token__
password: ${{ secrets.pypi_password }}
name: pydantic2ts-dist
path: dist/
- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ celerybeat.pid
# Environments
.env
.venv
.venv-v1
env/
venv/
ENV/
Expand Down Expand Up @@ -143,3 +144,7 @@ cython_debug/

# VS Code config
.vscode

# test outputs
output_debug.ts
schema_debug.json
11 changes: 5 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Pydantic to Typescript
description: |
Convert pydantic models into typescript definitions and ensure that your type definitions are in sync.
author: Phillip Dupuis

inputs:
python-module:
required: true
Expand Down Expand Up @@ -44,17 +43,17 @@ runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ">=3.6 <=3.10"
python-version: "3.x"
- name: Install pydantic-to-typescript
shell: bash
run: |
python -m pip install -U pip wheel pydantic-to-typescript
- name: Set up Node.js 16
uses: actions/setup-node@v3
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- name: Install json-schema-to-typescript
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions pydantic2ts/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from pydantic2ts.cli.script import generate_typescript_defs

__all__ = ("generate_typescript_defs",)
Loading