Skip to content

Commit 62ce01c

Browse files
authored
Fix CI (#1668)
1 parent dd22595 commit 62ce01c

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ jobs:
390390
steps:
391391
- uses: actions/setup-python@v5
392392
with:
393-
python-version: '3.12'
393+
python-version: "3.12"
394394
- name: Install dependencies
395395
run: pip install tweepy==4.14.0
396396
- name: Send tweet

docs/evals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ _(This example is complete, it can be run "as is")_
156156

157157
In this example we evaluate a method for generating recipes based on customer orders.
158158

159-
```python {title="judge_recipes.py"}
159+
```python {title="judge_recipes.py" test="skip"}
160160
from __future__ import annotations
161161

162162
from typing import Any
@@ -263,7 +263,7 @@ _(This example is complete, it can be run "as is")_
263263

264264
Datasets can be saved to and loaded from YAML or JSON files.
265265

266-
```python {title="save_load_dataset_example.py"}
266+
```python {title="save_load_dataset_example.py" test="skip"}
267267
from pathlib import Path
268268

269269
from judge_recipes import CustomerOrder, Recipe, recipe_dataset
@@ -695,7 +695,7 @@ You can send these traces to any OpenTelemetry-compatible backend, including [Py
695695

696696
All you need to do is configure Logfire via `logfire.configure`:
697697

698-
```python {title="logfire_integration.py"}
698+
```python {title="logfire_integration.py" test="skip"}
699699
import logfire
700700
from judge_recipes import recipe_dataset, transform_recipe
701701

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ include = [
114114
extend-select = [
115115
"Q",
116116
"RUF100",
117-
"RUF018", # https://docs.astral.sh/ruff/rules/assignment-in-assert/
117+
"RUF018", # https://docs.astral.sh/ruff/rules/assignment-in-assert/
118118
"C90",
119119
"UP",
120120
"I",
@@ -193,7 +193,7 @@ filterwarnings = [
193193
"ignore:websockets.server.WebSocketServerProtocol is deprecated:DeprecationWarning",
194194
# random resource warnings; I suspect these are coming from vendor SDKs when running examples..
195195
"ignore:unclosed <socket:ResourceWarning",
196-
"ignore:unclosed event loop:ResourceWarning"
196+
"ignore:unclosed event loop:ResourceWarning",
197197
]
198198

199199
# https://coverage.readthedocs.io/en/latest/config.html#run

tests/test_examples.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ def find_filter_examples() -> Iterable[ParameterSet]:
7474
yield pytest.param(ex, id=test_id)
7575

7676

77+
@pytest.fixture
78+
def reset_cwd():
79+
original_cwd = os.getcwd()
80+
try:
81+
yield
82+
finally:
83+
os.chdir(original_cwd)
84+
85+
7786
@pytest.mark.parametrize('example', find_filter_examples())
7887
def test_docs_examples( # noqa: C901
7988
example: CodeExample,
@@ -83,6 +92,7 @@ def test_docs_examples( # noqa: C901
8392
allow_model_requests: None,
8493
env: TestEnv,
8594
tmp_path: Path,
95+
reset_cwd: None,
8696
):
8797
mocker.patch('pydantic_ai.agent.models.infer_model', side_effect=mock_infer_model)
8898
mocker.patch('pydantic_ai._utils.group_by_temporal', side_effect=mock_group_by_temporal)
@@ -134,8 +144,6 @@ def print(self, *args: Any, **kwargs: Any) -> None:
134144
if sys.version_info < python_version_info:
135145
pytest.skip(f'Python version {python_version} required')
136146

137-
cwd = Path.cwd()
138-
139147
if opt_test.startswith('skip') and opt_lint.startswith('skip'):
140148
pytest.skip('both running code and lint skipped')
141149

@@ -189,7 +197,6 @@ def print(self, *args: Any, **kwargs: Any) -> None:
189197
else:
190198
module_dict = eval_example.run_print_check(example, call=call_name, module_globals=test_globals)
191199

192-
os.chdir(cwd)
193200
if title := opt_title:
194201
if title.endswith('.py'):
195202
module_name = title[:-3]

0 commit comments

Comments
 (0)