-
Notifications
You must be signed in to change notification settings - Fork 228
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
fix: pydantic 2.10.x breaking change #1095
Changes from 4 commits
4f423b6
fc2b38a
ee11cd9
b045335
848d14c
ce4ab1f
ae0d0a7
04bdc8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
name: Tests | ||
on: [ pull_request ] | ||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
pre-commit: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
from typing import Any, Type | ||
|
||
import pydantic | ||
from packaging.specifiers import SpecifierSet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to switch back to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree here, lets not introduce |
||
from packaging.version import Version | ||
from pydantic import BaseModel | ||
|
||
IS_PYDANTIC_V2 = int(pydantic.VERSION.split(".")[0]) >= 2 | ||
|
||
def is_version_valid(version, requirement): | ||
# Parse the requirement as a SpecifierSet | ||
specifiers = SpecifierSet(requirement) | ||
# Parse the version as a Version | ||
v = Version(version) | ||
# Check if the version satisfies the specifiers | ||
return v in specifiers | ||
|
||
|
||
IS_PYDANTIC_V2 = is_version_valid(pydantic.VERSION, ">=2") | ||
IS_PYDANTIC_V2_10 = is_version_valid(pydantic.VERSION, ">=2.10") | ||
|
||
if IS_PYDANTIC_V2: | ||
from pydantic import TypeAdapter | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure about this seemingly unrelated change.
Won't this run multiple jobs for a "PR open" and a "branch push"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi thanks to check this PR.
I used it in for CI tests on current branch before make the PR. That part has been removed now.