From a46fa7882d07b2a90e1adc53f095a75047956be9 Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:16:18 -0700 Subject: [PATCH 1/2] Use default pydantic deserializer --- harp/schema.py | 10 ++++++---- pyproject.toml | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/harp/schema.py b/harp/schema.py index d60b797..21db88d 100644 --- a/harp/schema.py +++ b/harp/schema.py @@ -1,8 +1,8 @@ from importlib import resources from os import PathLike from typing import TextIO, Union - -from pydantic_yaml import parse_yaml_raw_as +from pydantic import TypeAdapter +import yaml from harp.model import Model, Registers @@ -13,7 +13,8 @@ def _read_common_registers() -> Registers: file = resources.files(__package__) / "common.yml" with file.open("r") as fileIO: - return parse_yaml_raw_as(Registers, fileIO.read()) + raw_reg = yaml.safe_load(fileIO.read()) + return TypeAdapter(Registers).validate_python(raw_reg) def read_schema(file: Union[str, PathLike, TextIO], include_common_registers: bool = True) -> Model: @@ -37,7 +38,8 @@ def read_schema(file: Union[str, PathLike, TextIO], include_common_registers: bo with open(file) as fileIO: return read_schema(fileIO) else: - schema = parse_yaml_raw_as(Model, file.read()) + raw_schema = yaml.safe_load(file.read()) + schema = TypeAdapter(Model).validate_python(raw_schema) if "WhoAmI" not in schema.registers and include_common_registers: common = _read_common_registers() schema.registers = dict(common.registers, **schema.registers) diff --git a/pyproject.toml b/pyproject.toml index c8fcaac..2f1a66a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,8 @@ dynamic = ["version"] license = "MIT" dependencies = [ - "pydantic-yaml", + "pydantic", + "pyyaml", "pandas" ] From 5f0951794e1aaaf4bfb8ac32d7abd4a00d066f26 Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Fri, 11 Jul 2025 13:58:39 -0700 Subject: [PATCH 2/2] Linting --- harp/schema.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/harp/schema.py b/harp/schema.py index 21db88d..e97ae1a 100644 --- a/harp/schema.py +++ b/harp/schema.py @@ -1,8 +1,9 @@ from importlib import resources from os import PathLike from typing import TextIO, Union -from pydantic import TypeAdapter + import yaml +from pydantic import TypeAdapter from harp.model import Model, Registers