From 9311bd3286f6ca9516e60a273fe6a23ddaf20862 Mon Sep 17 00:00:00 2001 From: Lewis Gaul Date: Sun, 20 Oct 2024 00:02:05 +0100 Subject: [PATCH] Remove leftover Pydantic v1 handling --- python_on_whales/utils.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/python_on_whales/utils.py b/python_on_whales/utils.py index 2524d4e7..bebdce24 100644 --- a/python_on_whales/utils.py +++ b/python_on_whales/utils.py @@ -3,7 +3,6 @@ import subprocess import sys from datetime import datetime, timedelta -from importlib.metadata import version from pathlib import Path from queue import Queue from subprocess import PIPE, Popen @@ -36,14 +35,10 @@ ) PROJECT_ROOT = Path(__file__).parents[1] -PYDANTIC_V2 = version("pydantic").startswith("2.") def custom_parse_object_as(type_, obj: Any): - if PYDANTIC_V2: - return pydantic.TypeAdapter(type_).validate_python(obj) - else: - return pydantic.parse_obj_as(type_, obj) + return pydantic.TypeAdapter(type_).validate_python(obj) def title_if_necessary(string: str): @@ -93,16 +88,10 @@ def to_docker_camel(string): class DockerCamelModel(pydantic.BaseModel): - if PYDANTIC_V2: - model_config = pydantic.ConfigDict( - populate_by_name=True, - alias_generator=to_docker_camel, - ) - else: - - class Config: - alias_generator = to_docker_camel - allow_population_by_field_name = True + model_config = pydantic.ConfigDict( + populate_by_name=True, + alias_generator=to_docker_camel, + ) @overload