Skip to content
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

Drop support for pydantic v1 #630

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ jobs:
- test_system.py
- test_task.py
- test_volume.py
pydantic-version:
- pydantic==1.9
- pydantic==2.*
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -76,7 +73,6 @@ jobs:
- name: Setup
run: |
./scripts/ci-setup.sh
pip install --upgrade ${{ matrix.pydantic-version }}
- name: Run tests
run: |
python -m pytest -vv --no-runtime-skip --durations=10 tests/python_on_whales/components/${{ matrix.component }}
Expand Down
60 changes: 24 additions & 36 deletions python_on_whales/docker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,23 @@
class ClientVersion(DockerCamelModel):
platform: Optional[Dict[str, str]] = None
version: Optional[str] = None
if pydantic.VERSION.startswith("1."):
api_version: Optional[str] = None
else:
api_version: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("APIVersion", "ApiVersion")
),
] = None
api_version: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("APIVersion", "ApiVersion")
),
] = None
default_api_version: Optional[str] = None
git_commit: Optional[str] = None
go_version: Optional[str] = None
os: Optional[str] = None
arch: Optional[str] = None
if pydantic.VERSION.startswith("1."):
build_time: Optional[str] = None
else:
build_time: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("BuildTime", "BuiltTime")
),
] = None
build_time: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("BuildTime", "BuiltTime")
),
] = None
context: Optional[str] = None
experimental: Optional[bool] = None

Expand All @@ -70,30 +64,24 @@ class ServerVersion(DockerCamelModel):
platform: Optional[Dict[str, str]] = None
components: Optional[List[ServerVersionComponent]] = None
version: Optional[str] = None
if pydantic.VERSION.startswith("1."):
api_version: Optional[str] = None
else:
api_version: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("APIVersion", "ApiVersion")
),
] = None
api_version: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("APIVersion", "ApiVersion")
),
] = None
min_api_version: Optional[str] = None
git_commit: Optional[str] = None
go_version: Optional[str] = None
os: Optional[str] = None
arch: Optional[str] = None
kernel_version: Optional[str] = None
if pydantic.VERSION.startswith("1."):
build_time: Optional[str] = None
else:
build_time: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("BuildTime", "BuiltTime")
),
] = None
build_time: Annotated[
Optional[str],
pydantic.Field(
validation_alias=pydantic.AliasChoices("BuildTime", "BuiltTime")
),
] = None


class Version(DockerCamelModel):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pydantic>=1.9,<3,!=2.0.*
pydantic>=2,<3,!=2.0.*
requests
tqdm
typer>=0.4.1
Expand Down
Loading