DSPy: The framework for programming—not prompting—language models
Python
Use pydantic's `ConfigDict` for config; filter litellm warnings (#8659)
Kurt McKee8850b1f891ba
diff --git a/dspy/adapters/types/audio.py b/dspy/adapters/types/audio.pyindex 83e041562..f39d60bda 100644--- a/dspy/adapters/types/audio.py+++ b/dspy/adapters/types/audio.py@@ -21,10 +21,10 @@ class Audio(Type):data: straudio_format: str- model_config = {- "frozen": True,- "extra": "forbid",- }+ model_config = pydantic.ConfigDict(+ frozen=True,+ extra="forbid",+ )def format(self) -> list[dict[str, Any]]:try:diff --git a/dspy/adapters/types/history.py b/dspy/adapters/types/history.pyindex f91925aef..65867c55b 100644--- a/dspy/adapters/types/history.py+++ b/dspy/adapters/types/history.py@@ -60,9 +60,9 @@ class History(pydantic.BaseModel):messages: list[dict[str, Any]]- model_config = {- "frozen": True,- "str_strip_whitespace": True,- "validate_assignment": True,- "extra": "forbid",- }+ model_config = pydantic.ConfigDict(+ frozen=True,+ str_strip_whitespace=True,+ validate_assignment=True,+ extra="forbid",+ )diff --git a/dspy/adapters/types/image.py b/dspy/adapters/types/image.pyindex 32fb786ed..56e14801c 100644--- a/dspy/adapters/types/image.py+++ b/dspy/adapters/types/image.py@@ -21,12 +21,12 @@ except ImportError:class Image(Type):url: str- model_config = {- "frozen": True,- "str_strip_whitespace": True,- "validate_assignment": True,- "extra": "forbid",- }+ model_config = pydantic.ConfigDict(+ frozen=True,+ str_strip_whitespace=True,+ validate_assignment=True,+ extra="forbid",+ )def format(self) -> list[dict[str, Any]] | str:try:diff --git a/pyproject.toml b/pyproject.tomlindex 4e123312a..48db89f36 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -112,6 +112,14 @@ exclude_lines = ["continue",]+[tool.pytest.ini_options]+filterwarnings = [+ # litellm uses deprecated pydantic config classes sometimes.+ # The issue has been fixed repeatedly, but still keeps showing up.+ # For examples, see litellm PRs #6903, #7300, #8096, #9372, and #12528.+ "ignore:.+class-based `config` is deprecated, use ConfigDict:DeprecationWarning",+]+[tool.ruff]include = ["dspy/**/*.py", "tests/**/*.py"]exclude = [