Skip to content

Commit 38ba727

Browse files
authored
test with pydantic-ai-slim only (#103)
1 parent 8785aa3 commit 38ba727

File tree

7 files changed

+56
-41
lines changed

7 files changed

+56
-41
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
enable-cache: true
2727

2828
- name: Install dependencies
29-
run: uv sync --python 3.12 --frozen --all-extras --no-dev --group lint
29+
run: uv sync --python 3.12 --frozen --all-extras --all-packages --group lint
3030

3131
- uses: pre-commit/[email protected]
3232
with:
@@ -87,6 +87,7 @@ jobs:
8787
uv run
8888
--python 3.12
8989
--frozen
90+
--package pydantic-ai-slim
9091
--extra openai
9192
--extra vertexai
9293
--extra groq
@@ -116,9 +117,15 @@ jobs:
116117
enable-cache: true
117118

118119
- run: mkdir coverage
120+
121+
# run tests with just `pydantic-ai-slim` dependencies
122+
- run: uv run --frozen --package pydantic-ai-slim coverage run -m pytest
123+
env:
124+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-slim
125+
119126
- run: uv run --frozen coverage run -m pytest
120127
env:
121-
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
128+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-standard
122129

123130
- run: uv run --frozen --all-extras coverage run -m pytest
124131
env:
@@ -149,6 +156,7 @@ jobs:
149156
with:
150157
enable-cache: true
151158

159+
- run: uv sync --frozen --package pydantic-ai-slim
152160
- run: uv run --frozen coverage combine coverage
153161

154162
- run: uv run --frozen coverage html --show-contexts --title "PydanticAI coverage for ${{ github.sha }}"

pydantic_ai_slim/pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,18 @@ vertexai = ["google-auth>=2.36.0", "requests>=2.32.3"]
4747
groq = ["groq>=0.12.0"]
4848
logfire = ["logfire>=2.3"]
4949

50+
[dependency-groups]
51+
dev = [
52+
"anyio>=4.5.0",
53+
"devtools>=0.12.2",
54+
"coverage[toml]>=7.6.2",
55+
"dirty-equals>=0.8.0",
56+
"inline-snapshot>=0.14",
57+
"pytest>=8.3.3",
58+
"pytest-examples>=0.0.14",
59+
"pytest-mock>=3.14.0",
60+
"pytest-pretty>=1.2.0",
61+
]
62+
5063
[tool.hatch.build.targets.wheel]
5164
packages = ["pydantic_ai"]

pyproject.toml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,7 @@ pydantic-ai-examples = { workspace = true }
4646
members = ["pydantic_ai_slim", "pydantic_ai_examples"]
4747

4848
[dependency-groups]
49-
dev = [
50-
"anyio>=4.5.0",
51-
"devtools>=0.12.2",
52-
"coverage[toml]>=7.6.2",
53-
"dirty-equals>=0.8.0",
54-
"inline-snapshot>=0.14",
55-
"pytest>=8.3.3",
56-
"pytest-examples>=0.0.14",
57-
"pytest-mock>=3.14.0",
58-
"pytest-pretty>=1.2.0",
59-
]
49+
# dev dependencies are defined in `pydantic-ai-slim/pyproject.toml` to allow for minimal testing
6050
lint = [
6151
"mypy>=1.11.2",
6252
"pyright>=1.1.388",
@@ -142,7 +132,7 @@ filterwarnings = [
142132
[tool.coverage.run]
143133
# required to avoid warnings about files created by create_module fixture
144134
include = ["pydantic_ai_slim/**/*.py", "tests/**/*.py"]
145-
omit = ["tests/test_live.py"]
135+
omit = ["tests/test_live.py", "tests/example_modules/*.py"]
146136
branch = true
147137

148138
# https://coverage.readthedocs.io/en/latest/config.html#report

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def set(self, name: str, value: str) -> None:
5454
def remove(self, name: str) -> None:
5555
self.envars[name] = os.environ.pop(name, None)
5656

57-
def reset(self) -> None:
57+
def reset(self) -> None: # pragma: no cover
5858
for name, value in self.envars.items():
5959
if value is None:
6060
os.environ.pop(name, None)
@@ -132,13 +132,13 @@ def run(
132132
path.write_text(source_code)
133133
filename = str(path)
134134

135-
if module_name_prefix:
135+
if module_name_prefix: # pragma: no cover
136136
module_name = module_name_prefix + module_name
137137

138138
if rewrite_assertions:
139139
loader = AssertionRewritingHook(config=request.config)
140140
loader.mark_rewrite(module_name)
141-
else:
141+
else: # pragma: no cover
142142
loader = None
143143

144144
spec = importlib.util.spec_from_file_location(module_name, filename, loader=loader)

tests/models/test_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def create_mock_stream(
8989
) -> AsyncOpenAI:
9090
return cast(AsyncOpenAI, cls(stream=list(stream))) # pyright: ignore[reportArgumentType]
9191

92-
async def chat_completions_create(
92+
async def chat_completions_create( # pragma: no cover
9393
self, *_args: Any, stream: bool = False, **_kwargs: Any
9494
) -> chat.ChatCompletion | MockAsyncStream:
9595
if stream:

tests/test_streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ async def stream_structured_function(_messages: list[Message], _: AgentInfo) ->
245245
agent = Agent(FunctionModel(stream_function=stream_structured_function), result_type=tuple[str, int])
246246

247247
@agent.tool_plain
248-
async def ret_a(x: str) -> str:
248+
async def ret_a(x: str) -> str: # pragma: no cover
249249
return x
250250

251251
with pytest.raises(UnexpectedModelBehavior, match=r'Exceeded maximum retries \(1\) for result validation'):

uv.lock

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

0 commit comments

Comments
 (0)