Skip to content

Remove support for Pydantic < 2 #789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b4ced1b
remove support for pydantic < 2
aaravnavani May 25, 2024
f00afa4
lint
aaravnavani May 27, 2024
909a1e3
lint
aaravnavani May 27, 2024
d9964ff
import
aaravnavani May 28, 2024
f7a0073
run tests
aaravnavani May 28, 2024
ef6c834
pyproject
aaravnavani May 28, 2024
700c501
poetry lock
aaravnavani May 28, 2024
96eb60e
poetry lockg
aaravnavani May 28, 2024
d142562
fix ci
aaravnavani May 28, 2024
700c285
reset pyproject and poetry lock
aaravnavani May 28, 2024
419aa58
revert updates
aaravnavani May 28, 2024
3047e25
update pyproject
aaravnavani May 28, 2024
4564f31
remove pytest check
aaravnavani Jun 4, 2024
f9b1f8a
lint
aaravnavani Jun 4, 2024
f5f0292
resolve comments
aaravnavani Jun 5, 2024
fc0e696
resolve comments
aaravnavani Jun 5, 2024
e82f46f
poetry lock conflict
aaravnavani Jun 5, 2024
1df1d2a
resolve conflict
aaravnavani Jun 5, 2024
c59c3e2
run poetry lock no update
aaravnavani Jun 5, 2024
d160a79
poetry lock
aaravnavani Jun 5, 2024
1d6d005
pytest
aaravnavani Jun 5, 2024
2ab9a23
resolve pydantic version
aaravnavani Jun 5, 2024
cb727a9
lint
aaravnavani Jun 5, 2024
5f22531
remove changes on test python rail
aaravnavani Jun 5, 2024
04b66b6
fix pydantic utils
aaravnavani Jun 5, 2024
bd2d552
Merge branch '0.5.0-dev' into remove_support_old_pydantic
CalebCourier Jun 17, 2024
98b7807
delete pydantic v1 tests
CalebCourier Jun 17, 2024
c107351
run PR checks against version branches
CalebCourier Jun 17, 2024
469911a
update lock file
CalebCourier Jun 17, 2024
9d3ed1b
type fixes and cleanup
CalebCourier Jun 17, 2024
f2e1c97
cleanup test
CalebCourier Jun 17, 2024
dd3657b
fix test
CalebCourier Jun 17, 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
31 changes: 3 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- main
- dev
- feat/*
- 0.*.*

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -27,12 +28,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# - name: Poetry cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pypoetry
# key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1

Expand All @@ -50,30 +45,20 @@ jobs:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
pydantic-version: ["==1.10.9", ">=2.x"]
openai-version: [">=1.x"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# - name: Poetry cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pypoetry
# key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}-${{ matrix.pydantic-version }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
# TODO: fix errors so that we can run `make dev` instead
run: |
make full
poetry run pip install "pydantic${{ matrix.pydantic-version }}"
poetry run pip install "openai${{ matrix.openai-version }}"

- name: Static analysis with pyright
run: |
Expand All @@ -86,9 +71,7 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11"]
# TODO: fix errors so that we can run both `make dev` and `make full`
# dependencies: ['dev', 'full']
dependencies: ["full"]
pydantic-version: ["==1.10.9", ">=2.x"]
openai-version: [">=1.x"]
# dependencies: ["full"]
steps:
- uses: actions/checkout@v4

Expand All @@ -102,20 +85,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# - name: Poetry cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pypoetry
# key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}-${{ matrix.pydantic-version }}-${{ matrix.openai-version }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
run: |
make ${{ matrix.dependencies }}
poetry run pip install "pydantic${{ matrix.pydantic-version }}"
poetry run pip install "openai${{ matrix.openai-version }}"
make full

- name: Run Pytests
run: |
Expand Down
4 changes: 2 additions & 2 deletions guardrails/schema/pydantic_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from guardrails.validator_base import Validator


def _resolve_alias(alias: str | AliasPath | AliasChoices) -> List[str]:
def _resolve_alias(alias: Union[str, AliasPath, AliasChoices]) -> List[str]:
aliases = []
if isinstance(alias, str):
aliases.append(alias)
Expand All @@ -41,7 +41,7 @@ def _resolve_alias(alias: str | AliasPath | AliasChoices) -> List[str]:


def _collect_aliases(
field: FieldInfo | AliasGenerator, field_name: str, model: Type[BaseModel]
field: Union[FieldInfo, AliasGenerator], field_name: str, model: Type[BaseModel]
) -> List[str]:
aliases = []

Expand Down
11 changes: 0 additions & 11 deletions guardrails/utils/dataclass.py

This file was deleted.

17 changes: 0 additions & 17 deletions guardrails/utils/pydantic_utils/__init__.py

This file was deleted.

132 changes: 0 additions & 132 deletions guardrails/utils/pydantic_utils/v1.py

This file was deleted.

2 changes: 1 addition & 1 deletion guardrails/validator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from guardrails.constants import hub
from guardrails.errors import ValidationError
from guardrails.types.on_fail import OnFailAction
from guardrails.utils.dataclass import dataclass
from dataclasses import dataclass

VALIDATOR_IMPORT_WARNING = """Accessing `{validator_name}` using
`from guardrails.validators import {validator_name}` is deprecated and
Expand Down
Loading
Loading