Files
wehub-resource-sync 9201ef759e
CI / lint (push) Waiting to run
CI / mypy (push) Waiting to run
CI / docs (push) Waiting to run
CI / test on 3.10 (standard) (push) Waiting to run
CI / test on 3.11 (standard) (push) Waiting to run
CI / test on 3.12 (standard) (push) Waiting to run
CI / test on 3.10 (all-extras) (push) Waiting to run
CI / test on 3.11 (all-extras) (push) Waiting to run
CI / test on 3.12 (all-extras) (push) Waiting to run
CI / test on 3.13 (all-extras) (push) Waiting to run
CI / test on 3.14 (pydantic-evals) (push) Waiting to run
Harness Compat / harness compat (push) Waiting to run
CI / test on 3.13 (standard) (push) Waiting to run
CI / test on 3.14 (standard) (push) Waiting to run
CI / test on 3.14 (all-extras) (push) Waiting to run
CI / test on 3.10 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.11 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.12 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.13 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.14 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.10 (pydantic-evals) (push) Waiting to run
CI / test on 3.11 (pydantic-evals) (push) Waiting to run
CI / test on 3.12 (pydantic-evals) (push) Waiting to run
CI / test on 3.13 (pydantic-evals) (push) Waiting to run
CI / test on 3.10 (lowest-versions) (push) Waiting to run
CI / test on 3.11 (lowest-versions) (push) Waiting to run
CI / test on 3.12 (lowest-versions) (push) Waiting to run
CI / test on 3.13 (lowest-versions) (push) Waiting to run
CI / test on 3.14 (lowest-versions) (push) Waiting to run
CI / test examples on 3.11 (push) Waiting to run
CI / test examples on 3.12 (push) Waiting to run
CI / test examples on 3.13 (push) Waiting to run
CI / test examples on 3.14 (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / check (push) Blocked by required conditions
CI / deploy-docs (push) Blocked by required conditions
CI / deploy-docs-preview (push) Blocked by required conditions
CI / build release artifacts (push) Blocked by required conditions
CI / publish to PyPI (push) Blocked by required conditions
CI / Send tweet (push) Blocked by required conditions
chore: import upstream snapshot with attribution
2026-07-13 13:27:52 +08:00

51 lines
1.7 KiB
Python

from __future__ import annotations as _annotations
import os
from collections.abc import Iterable
from dataclasses import dataclass, field
from pathlib import Path
import pytest
from _pytest.mark import ParameterSet
from pytest_examples import CodeExample, EvalExample, find_examples
from pytest_examples.config import ExamplesConfig as BaseExamplesConfig
@dataclass
class ExamplesConfig(BaseExamplesConfig):
known_first_party: list[str] = field(default_factory=list[str])
def ruff_config(self) -> tuple[str, ...]:
config = super().ruff_config()
if self.known_first_party: # pragma: no branch
config = (*config, '--config', f'lint.isort.known-first-party = {self.known_first_party}')
return config
def find_skill_examples() -> Iterable[ParameterSet]:
# Skill examples are package assets for agents, not executable docs pages.
# Lint them to catch stale Python snippets without running model/file-system examples.
root_dir = Path(__file__).parent.parent
os.chdir(root_dir)
for ex in find_examples('pydantic_ai_slim/pydantic_ai/.agents'):
try:
path = ex.path.relative_to(root_dir)
except ValueError:
path = ex.path
yield pytest.param(ex, id=f'{path}:{ex.start_line}')
@pytest.mark.parametrize('example', list(find_skill_examples()))
def test_skill_examples_lint(example: CodeExample, eval_example: EvalExample):
eval_example.config = ExamplesConfig(
ruff_ignore=['D', 'Q001'],
target_version='py310',
line_length=120,
isort=True,
upgrade=True,
quotes='single',
known_first_party=['pydantic_ai', 'pydantic_evals', 'pydantic_graph'],
)
eval_example.lint_ruff(example)