Skip to content

Commit b5d66a6

Browse files
authored
Support python 3.13 (#8255)
* support python 3.13 * allow 3.14 * fix flaky tests
1 parent fddba54 commit b5d66a6

File tree

8 files changed

+471
-18
lines changed

8 files changed

+471
-18
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description = "DSPy"
1313
readme = "README.md"
1414
authors = [{ name = "Omar Khattab", email = "okhattab@stanford.edu" }]
1515
license = { text = "MIT License" }
16-
requires-python = ">=3.9, <3.13"
16+
requires-python = ">=3.9, <3.14"
1717
classifiers = [
1818
"Development Status :: 3 - Alpha",
1919
"Intended Audience :: Science/Research",

tests/clients/test_embedding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async def test_async_embedding():
113113
mock_litellm.return_value = MockEmbeddingResponse(mock_embeddings)
114114

115115
# Create embedding instance and call it.
116-
embedding = Embedder(model)
116+
embedding = Embedder(model, caching=False)
117117
result = await embedding.acall(inputs)
118118

119119
# Verify litellm was called with correct parameters.

tests/clients/test_lm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ async def test_async_lm_call():
329329
with patch("litellm.acompletion") as mock_acompletion:
330330
mock_acompletion.return_value = mock_response
331331

332-
lm = dspy.LM(model="openai/gpt-4o-mini")
332+
lm = dspy.LM(model="openai/gpt-4o-mini", cache=False)
333333
result = await lm.acall("question")
334334

335335
assert result == ["answer"]

tests/primitives/test_tool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,14 @@ def fn(x: int, **kwargs):
254254

255255

256256
def test_tool_str():
257-
tool = Tool(dummy_function)
257+
def add(x: int, y: int = 0) -> int:
258+
"""Add two integers."""
259+
return x + y
260+
261+
tool = Tool(add)
258262
assert (
259263
str(tool)
260-
== "dummy_function, whose description is <desc>A dummy function for testing. Args: x: An integer parameter y: A string parameter </desc>. It takes arguments {'x': {'type': 'integer'}, 'y': {'type': 'string', 'default': 'hello'}} in JSON format."
264+
== "add, whose description is <desc>Add two integers.</desc>. It takes arguments {'x': {'type': 'integer'}, 'y': {'type': 'integer', 'default': 0}} in JSON format."
261265
)
262266

263267

tests/streaming/test_streaming.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class TestSignature(dspy.Signature):
2727
program = dspy.streamify(dspy.Predict(TestSignature))
2828
output_stream1 = program(input_text="Test")
2929
output_chunks1 = [chunk async for chunk in output_stream1]
30-
assert len(output_chunks1) > 1
3130
last_chunk1 = output_chunks1[-1]
3231
assert isinstance(last_chunk1, dspy.Prediction)
3332
assert last_chunk1.output_text == "Hello!"

tests/test_utils/server/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
import socket
44
import subprocess
5-
import sys
65
import tempfile
76
import time
87
from typing import Any, Dict, List, Tuple

tests/utils/test_saving.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def emit(self, record):
107107

108108
try:
109109
# Mock version during save
110-
with patch("dspy.utils.saving.get_dependency_versions", return_value=save_versions):
110+
with patch("dspy.primitives.module.get_dependency_versions", return_value=save_versions):
111111
predict.save(tmp_path, save_program=True)
112112

113113
# Mock version during load

uv.lock

Lines changed: 461 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)