|
7 | 7 | from datetime import date, datetime
|
8 | 8 | from functools import cached_property
|
9 | 9 | from pathlib import Path
|
10 |
| -from typing import Any, Dict, Optional, Union, Annotated |
| 10 | +from typing import Annotated, Any, Dict, Optional, Union |
11 | 11 |
|
12 | 12 | import pydantic
|
13 | 13 | import tzlocal
|
14 | 14 | from bson import ObjectId
|
15 | 15 | from hostlist import expand_hostlist
|
16 |
| -from pydantic import field_validator, Field, ConfigDict, BaseModel as _BaseModel, AfterValidator |
| 16 | +from pydantic import AfterValidator |
| 17 | +from pydantic import BaseModel as _BaseModel |
| 18 | +from pydantic import ConfigDict, Field, field_validator |
17 | 19 |
|
18 | 20 | MTL = zoneinfo.ZoneInfo("America/Montreal")
|
19 | 21 | PST = zoneinfo.ZoneInfo("America/Vancouver")
|
@@ -41,7 +43,12 @@ def validate_date(value: Union[str, date, datetime]) -> date:
|
41 | 43 | class BaseModel(_BaseModel):
|
42 | 44 | # TODO[pydantic]: The following keys were removed: `json_encoders`.
|
43 | 45 | # Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-config for more information.
|
44 |
| - model_config = ConfigDict(extra="forbid", ignored_types=(cached_property,), json_encoders={ObjectId: str}, arbitrary_types_allowed=True) |
| 46 | + model_config = ConfigDict( |
| 47 | + extra="forbid", |
| 48 | + ignored_types=(cached_property,), |
| 49 | + json_encoders={ObjectId: str}, |
| 50 | + arbitrary_types_allowed=True, |
| 51 | + ) |
45 | 52 |
|
46 | 53 | def dict(self, *args, **kwargs) -> dict[str, Any]:
|
47 | 54 | d = super().dict(*args, **kwargs)
|
@@ -257,7 +264,6 @@ class ScraperConfig(BaseModel):
|
257 | 264 | loki: LokiConfig = None
|
258 | 265 | tempo: TempoConfig = None
|
259 | 266 |
|
260 |
| - |
261 | 267 | @field_validator("clusters", mode="after")
|
262 | 268 | @classmethod
|
263 | 269 | def _complete_cluster_fields(cls, value, info):
|
@@ -300,7 +306,7 @@ def parse_config(config_path, config_cls=Config):
|
300 | 306 | )
|
301 | 307 |
|
302 | 308 | try:
|
303 |
| - with open(config_path) as f: |
| 309 | + with open(config_path, encoding="utf-8") as f: |
304 | 310 | cfg = config_cls.model_validate_json(f.read())
|
305 | 311 | except json.JSONDecodeError as exc:
|
306 | 312 | raise ConfigurationError(f"'{config_path}' contains malformed JSON") from exc
|
|
0 commit comments