Skip to content

Commit f9b894b

Browse files
committed
chore: Bump Pydantic to v2 implementation
1 parent d825b2d commit f9b894b

File tree

1 file changed

+9
-10
lines changed
  • agents_mcp_usage/multi_mcp/eval_multi_mcp

1 file changed

+9
-10
lines changed

agents_mcp_usage/multi_mcp/eval_multi_mcp/schemas.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Pydantic Schemas for Dashboard Configuration Validation
33
"""
44

5-
from pydantic import BaseModel, Field, validator
6-
from typing import List, Dict, Optional, Any
5+
from pydantic import BaseModel, Field, field_validator, model_validator
6+
from typing import List, Dict, Optional
77

88

99
class PrimaryMetricConfig(BaseModel):
@@ -15,7 +15,8 @@ class PrimaryMetricConfig(BaseModel):
1515
description="Optional source column to calculate the primary metric from if it doesn't exist.",
1616
)
1717

18-
@validator("goal")
18+
@field_validator("goal")
19+
@classmethod
1920
def goal_must_be_max_or_min(cls, v: str) -> str:
2021
"""Validates that the goal is either 'maximize' or 'minimize'."""
2122
if v not in ["maximize", "minimize"]:
@@ -65,17 +66,15 @@ class BarPlotConfig(BaseModel):
6566
y_columns: Optional[List[str]] = None
6667
series: Optional[List[StackedBarPlotSeries]] = None
6768

68-
@validator("y_columns", always=True)
69-
def check_prefix_or_columns(
70-
cls, v: Optional[List[str]], values: Dict[str, Any]
71-
) -> Optional[List[str]]:
69+
@model_validator(mode="after")
70+
def check_prefix_or_columns(self) -> "BarPlotConfig":
7271
"""Validates that either 'y_prefix' or 'y_columns' is provided for grouped_bar plots."""
73-
if not values.get("y_prefix") and not v:
74-
if values.get("type") == "grouped_bar":
72+
if not self.y_prefix and not self.y_columns:
73+
if self.type == "grouped_bar":
7574
raise ValueError(
7675
"Either 'y_prefix' or 'y_columns' must be provided for grouped_bar plots."
7776
)
78-
return v
77+
return self
7978

8079

8180
class PlotConfig(BaseModel):

0 commit comments

Comments
 (0)