From 2afc6d719b6741ca199df24a0e0e150c4ace3509 Mon Sep 17 00:00:00 2001 From: Mateusz Kulewicz Date: Fri, 9 Aug 2024 15:03:53 +0200 Subject: [PATCH] Fix pydantic models by dropping importing v1 (#167) --- lib/charms/grafana_agent/v0/cos_agent.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/charms/grafana_agent/v0/cos_agent.py b/lib/charms/grafana_agent/v0/cos_agent.py index 2a3e1fe..582b70c 100644 --- a/lib/charms/grafana_agent/v0/cos_agent.py +++ b/lib/charms/grafana_agent/v0/cos_agent.py @@ -228,6 +228,7 @@ def __init__(self, *args): Union, ) +import pydantic from cosl import GrafanaDashboard, JujuTopology from cosl.rules import AlertRules from ops.charm import RelationChangedEvent @@ -235,11 +236,6 @@ def __init__(self, *args): from ops.model import ModelError, Relation from ops.testing import CharmType -try: - import pydantic.v1 as pydantic -except ImportError: - import pydantic - if TYPE_CHECKING: try: from typing import TypedDict @@ -253,7 +249,7 @@ class _MetricsEndpointDict(TypedDict): LIBID = "dc15fa84cef84ce58155fb84f6c6213a" LIBAPI = 0 -LIBPATCH = 9 +LIBPATCH = 10 PYDEPS = ["cosl", "pydantic"] @@ -408,6 +404,7 @@ class DatabagModel(pydantic.BaseModel): # Custom config key: whether to nest the whole datastructure (as json) # under a field or spread it out at the toplevel. _NEST_UNDER=None, # type: ignore + arbitrary_types_allowed=True, ) """Pydantic config."""