Skip to content

Commit 72ddc53

Browse files
authored
Resolve pydantic config warnings (#479)
1 parent 177bf37 commit 72ddc53

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

doc/changes/unreleased.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Unreleased
22

3+
## Refactoring
4+
* Switched deprecated Pydantic class-based `config` to `ConfigDict`
5+
36
## Security
4-
* #477: Switched `sonar:check` to use `SONAR_TOKEN` from the environment
7+
* #477: Switched `sonar:check` to use `SONAR_TOKEN` from the environment

exasol/toolbox/util/dependencies/poetry_dependencies.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
11
from __future__ import annotations
22

3-
import re
43
import subprocess
5-
import sys
64
from pathlib import Path
75
from typing import Optional
86

97
import tomlkit
108
from pydantic import (
119
BaseModel,
10+
ConfigDict,
1211
)
1312
from tomlkit import TOMLDocument
1413

1514
from exasol.toolbox.util.dependencies.shared_models import Package
1615

1716

1817
class PoetryGroup(BaseModel):
18+
model_config = ConfigDict(frozen=True)
19+
1920
name: str
2021
toml_section: Optional[str]
2122

22-
class Config:
23-
frozen = True
24-
2523

2624
TRANSITIVE_GROUP = PoetryGroup(name="transitive", toml_section=None)
2725

2826

2927
class PoetryToml(BaseModel):
30-
content: TOMLDocument
28+
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
3129

32-
class Config:
33-
frozen = True
34-
arbitrary_types_allowed = True
30+
content: TOMLDocument
3531

3632
@classmethod
3733
def load_from_toml(cls, working_directory: Path) -> PoetryToml:

exasol/toolbox/util/dependencies/shared_models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
from packaging.version import Version
44
from pydantic import (
55
BaseModel,
6+
ConfigDict,
67
field_validator,
78
)
89

910

1011
class Package(BaseModel):
12+
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
13+
1114
name: str
1215
version: Version
1316

14-
class Config:
15-
frozen = True
16-
arbitrary_types_allowed = True
17-
1817
@field_validator("version", mode="before")
1918
def convert_version(cls, v: str) -> Version:
2019
return Version(v)

0 commit comments

Comments
 (0)