Skip to content

Commit

Permalink
Make cos_agent lib compatible with Pydantic v1/v2 (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiiwang01 authored Aug 8, 2024
1 parent 115bb39 commit df353b1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/charms/grafana_agent/v0/cos_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,18 @@ def __init__(self, *args):
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Dict, List, Optional, Set, Tuple, Union

import pydantic
from cosl import GrafanaDashboard, JujuTopology
from cosl.rules import AlertRules
from ops.charm import RelationChangedEvent
from ops.framework import EventBase, EventSource, Object, ObjectEvents
from ops.model import Relation
from ops.testing import CharmType

try:
import pydantic.v1 as pydantic
except ImportError:
import pydantic

if TYPE_CHECKING:
try:
from typing import TypedDict
Expand All @@ -234,9 +238,9 @@ class _MetricsEndpointDict(TypedDict):

LIBID = "dc15fa84cef84ce58155fb84f6c6213a"
LIBAPI = 0
LIBPATCH = 8
LIBPATCH = 9

PYDEPS = ["cosl", "pydantic < 2"]
PYDEPS = ["cosl", "pydantic"]

DEFAULT_RELATION_NAME = "cos-agent"
DEFAULT_PEER_RELATION_NAME = "peers"
Expand Down

0 comments on commit df353b1

Please sign in to comment.