Skip to content

generate StrEnum for python 3.11+ #702

generate StrEnum for python 3.11+

generate StrEnum for python 3.11+ #702

name: python
on:
pull_request:
paths:
- "generators/python/**"
branches:
- main
workflow_call:
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install Dependencies
working-directory: ./generators/python
run: poetry install
- name: Type check
working-directory: ./generators/python
run: poetry run mypy
- name: pre-commit
working-directory: ./generators/python
run: poetry run pre-commit run --all-files
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Update models for testing
working-directory: ./generators/python
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
npm install -g fern-api
docker build -f ./pydantic/Dockerfile -t ferntest/fern-pydantic-model:0.0.0 .
cd tests/utils/example_models
fern generate --group dummy_types --local
- name: Install Dependencies - Pydantic V1
working-directory: ./generators/python
run: |
poetry add pydantic=^1.10
poetry lock
poetry install
- name: Unit Test - Pydantic V1
working-directory: ./generators/python
run: poetry run pytest -sv
- name: Install Dependencies - Pydantic V2
working-directory: ./generators/python
run: |
poetry remove fern-fern-generator-exec-sdk
poetry add pydantic=^2.8
poetry lock
poetry install
- name: Unit Test - Pydantic V2
working-directory: ./generators/python
# Run specific tests:
# Some tests pull in dependencies that have older versions of internal SDKs installed, which are
# incompatible with Pydantic V2 outright (specifically the use of __root__ in unions with utils).
run: poetry run pytest -sv ./tests/utils/ --ignore ./tests/utils/casing