Skip to content

Commit 8850b1f

Browse files
authored
Use pydantic's ConfigDict for config; filter litellm warnings (stanfordnlp#8659)
1 parent d836fd8 commit 8850b1f

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

dspy/adapters/types/audio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class Audio(Type):
2121
data: str
2222
audio_format: str
2323

24-
model_config = {
25-
"frozen": True,
26-
"extra": "forbid",
27-
}
24+
model_config = pydantic.ConfigDict(
25+
frozen=True,
26+
extra="forbid",
27+
)
2828

2929
def format(self) -> list[dict[str, Any]]:
3030
try:

dspy/adapters/types/history.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ class MySignature(dspy.Signature):
6060

6161
messages: list[dict[str, Any]]
6262

63-
model_config = {
64-
"frozen": True,
65-
"str_strip_whitespace": True,
66-
"validate_assignment": True,
67-
"extra": "forbid",
68-
}
63+
model_config = pydantic.ConfigDict(
64+
frozen=True,
65+
str_strip_whitespace=True,
66+
validate_assignment=True,
67+
extra="forbid",
68+
)

dspy/adapters/types/image.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
class Image(Type):
2222
url: str
2323

24-
model_config = {
25-
"frozen": True,
26-
"str_strip_whitespace": True,
27-
"validate_assignment": True,
28-
"extra": "forbid",
29-
}
24+
model_config = pydantic.ConfigDict(
25+
frozen=True,
26+
str_strip_whitespace=True,
27+
validate_assignment=True,
28+
extra="forbid",
29+
)
3030

3131
def format(self) -> list[dict[str, Any]] | str:
3232
try:

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ exclude_lines = [
112112
"continue",
113113
]
114114

115+
[tool.pytest.ini_options]
116+
filterwarnings = [
117+
# litellm uses deprecated pydantic config classes sometimes.
118+
# The issue has been fixed repeatedly, but still keeps showing up.
119+
# For examples, see litellm PRs #6903, #7300, #8096, #9372, and #12528.
120+
"ignore:.+class-based `config` is deprecated, use ConfigDict:DeprecationWarning",
121+
]
122+
115123
[tool.ruff]
116124
include = ["dspy/**/*.py", "tests/**/*.py"]
117125
exclude = [

0 commit comments

Comments
 (0)