Skip to content

Commit ab27b3c

Browse files
dsfacciniclaude
andcommitted
fix: only pass parser_options to griffe for google-style docstrings
The `returns_named_value` and `returns_multiple_items` options are only valid for the Google docstring parser. Passing them to Sphinx/Numpy parsers now triggers a DeprecationWarning in griffe. Also fixed cross-reference paths in docstrings to use the full module path (e.g. `pydantic_ai.agent.Agent` instead of `pydantic_ai.Agent`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 08d0898 commit ab27b3c

File tree

8 files changed

+24
-20
lines changed

8 files changed

+24
-20
lines changed

pydantic_ai_slim/pydantic_ai/_griffe.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from inspect import Signature
88
from typing import TYPE_CHECKING, Any, Literal, cast
99

10-
from griffe import Docstring, DocstringSectionKind, Object as GriffeObject
10+
from griffe import Docstring, DocstringSectionKind, GoogleOptions, Object as GriffeObject
1111

1212
if TYPE_CHECKING:
1313
from .tools import DocstringFormat
@@ -42,13 +42,17 @@ def doc_descriptions(
4242
parent = cast(GriffeObject, sig)
4343

4444
docstring_style = _infer_docstring_style(doc) if docstring_format == 'auto' else docstring_format
45+
# These options are only valid for Google-style docstrings
46+
# https://mkdocstrings.github.io/griffe/reference/docstrings/#google-options
47+
parser_options = (
48+
GoogleOptions(returns_named_value=False, returns_multiple_items=False) if docstring_style == 'google' else None
49+
)
4550
docstring = Docstring(
4651
doc,
4752
lineno=1,
4853
parser=docstring_style,
4954
parent=parent,
50-
# https://mkdocstrings.github.io/griffe/reference/docstrings/#google-options
51-
parser_options={'returns_named_value': False, 'returns_multiple_items': False},
55+
parser_options=parser_options,
5256
)
5357
with _disable_griffe_logging():
5458
sections = docstring.parse()

pydantic_ai_slim/pydantic_ai/agent/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def __init__(
242242
output_type: The type of the output data, used to validate the data returned by the model,
243243
defaults to `str`.
244244
instructions: Instructions to use for this agent, you can also register instructions via a function with
245-
[`instructions`][pydantic_ai.Agent.instructions] or pass additional, temporary, instructions when executing a run.
245+
[`instructions`][pydantic_ai.agent.Agent.instructions] or pass additional, temporary, instructions when executing a run.
246246
system_prompt: Static system prompts to use for this agent, you can also register system
247-
prompts via a function with [`system_prompt`][pydantic_ai.Agent.system_prompt].
247+
prompts via a function with [`system_prompt`][pydantic_ai.agent.Agent.system_prompt].
248248
deps_type: The type used for dependency injection, this parameter exists solely to allow you to fully
249249
parameterize the agent, and therefore get the best out of static type checking.
250250
If you're not using deps, but want type checking to pass, you can set `deps=None` to satisfy Pyright
@@ -257,7 +257,7 @@ def __init__(
257257
validation_context: Pydantic [validation context](https://docs.pydantic.dev/latest/concepts/validators/#validation-context) used to validate tool arguments and outputs.
258258
output_retries: The maximum number of retries to allow for output validation, defaults to `retries`.
259259
tools: Tools to register with the agent, you can also register tools via the decorators
260-
[`@agent.tool`][pydantic_ai.Agent.tool] and [`@agent.tool_plain`][pydantic_ai.Agent.tool_plain].
260+
[`@agent.tool`][pydantic_ai.agent.Agent.tool] and [`@agent.tool_plain`][pydantic_ai.agent.Agent.tool_plain].
261261
builtin_tools: The builtin tools that the agent will use. This depends on the model, as some models may not
262262
support certain tools. If the model doesn't support the builtin tools, an error will be raised.
263263
prepare_tools: Custom function to prepare the tool definition of all tools for each step, except output tools.
@@ -272,14 +272,14 @@ def __init__(
272272
it's evaluated to create a [`Model`][pydantic_ai.models.Model] instance immediately,
273273
which checks for the necessary environment variables. Set this to `false`
274274
to defer the evaluation until the first run. Useful if you want to
275-
[override the model][pydantic_ai.Agent.override] for testing.
275+
[override the model][pydantic_ai.agent.Agent.override] for testing.
276276
end_strategy: Strategy for handling tool calls that are requested alongside a final result.
277277
See [`EndStrategy`][pydantic_ai.agent.EndStrategy] for more information.
278278
instrument: Set to True to automatically instrument with OpenTelemetry,
279279
which will use Logfire if it's configured.
280280
Set to an instance of [`InstrumentationSettings`][pydantic_ai.agent.InstrumentationSettings] to customize.
281281
If this isn't set, then the last value set by
282-
[`Agent.instrument_all()`][pydantic_ai.Agent.instrument_all]
282+
[`Agent.instrument_all()`][pydantic_ai.agent.Agent.instrument_all]
283283
will be used, which defaults to False.
284284
See the [Debugging and Monitoring guide](https://ai.pydantic.dev/logfire/) for more info.
285285
history_processors: Optional list of callables to process the message history before sending it to the model.

pydantic_ai_slim/pydantic_ai/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class SystemPromptPart:
8686
dynamic_ref: str | None = None
8787
"""The ref of the dynamic system prompt function that generated this part.
8888
89-
Only set if system prompt is dynamic, see [`system_prompt`][pydantic_ai.Agent.system_prompt] for more information.
89+
Only set if system prompt is dynamic, see [`system_prompt`][pydantic_ai.agent.Agent.system_prompt] for more information.
9090
"""
9191

9292
part_kind: Literal['system-prompt'] = 'system-prompt'

pydantic_ai_slim/pydantic_ai/models/function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ class AgentInfo:
211211
function_tools: list[ToolDefinition]
212212
"""The function tools available on this agent.
213213
214-
These are the tools registered via the [`tool`][pydantic_ai.Agent.tool] and
215-
[`tool_plain`][pydantic_ai.Agent.tool_plain] decorators.
214+
These are the tools registered via the [`tool`][pydantic_ai.agent.Agent.tool] and
215+
[`tool_plain`][pydantic_ai.agent.Agent.tool_plain] decorators.
216216
"""
217217
allow_text_output: bool
218218
"""Whether a plain text output is allowed."""

pydantic_ai_slim/pydantic_ai/ui/_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class StateDeps(Generic[StateT]):
104104
class UIAdapter(ABC, Generic[RunInputT, MessageT, EventT, AgentDepsT, OutputDataT]):
105105
"""Base class for UI adapters.
106106
107-
This class is responsible for transforming agent run input received from the frontend into arguments for [`Agent.run_stream_events()`][pydantic_ai.Agent.run_stream_events], running the agent, and then transforming Pydantic AI events into protocol-specific events.
107+
This class is responsible for transforming agent run input received from the frontend into arguments for [`Agent.run_stream_events()`][pydantic_ai.agent.Agent.run_stream_events], running the agent, and then transforming Pydantic AI events into protocol-specific events.
108108
109109
The event stream transformation is handled by a protocol-specific [`UIEventStream`][pydantic_ai.ui.UIEventStream] subclass.
110110
"""

pydantic_evals/pydantic_evals/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def evaluate_sync(
372372
) -> EvaluationReport[InputsT, OutputT, MetadataT]:
373373
"""Evaluates the test cases in the dataset using the given task.
374374
375-
This is a synchronous wrapper around [`evaluate`][pydantic_evals.Dataset.evaluate] provided for convenience.
375+
This is a synchronous wrapper around [`evaluate`][pydantic_evals.dataset.Dataset.evaluate] provided for convenience.
376376
377377
Args:
378378
task: The task to evaluate. This should be a callable that takes the inputs of the case

pydantic_evals/pydantic_evals/reporting/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class ReportCase(Generic[InputsT, OutputT, MetadataT]):
5555
name: str
5656
"""The name of the [case][pydantic_evals.Case]."""
5757
inputs: InputsT
58-
"""The inputs to the task, from [`Case.inputs`][pydantic_evals.Case.inputs]."""
58+
"""The inputs to the task, from [`Case.inputs`][pydantic_evals.dataset.Case.inputs]."""
5959
metadata: MetadataT | None
60-
"""Any metadata associated with the case, from [`Case.metadata`][pydantic_evals.Case.metadata]."""
60+
"""Any metadata associated with the case, from [`Case.metadata`][pydantic_evals.dataset.Case.metadata]."""
6161
expected_output: OutputT | None
62-
"""The expected output of the task, from [`Case.expected_output`][pydantic_evals.Case.expected_output]."""
62+
"""The expected output of the task, from [`Case.expected_output`][pydantic_evals.dataset.Case.expected_output]."""
6363
output: OutputT
6464
"""The output of the task execution."""
6565

@@ -88,11 +88,11 @@ class ReportCaseFailure(Generic[InputsT, OutputT, MetadataT]):
8888
name: str
8989
"""The name of the [case][pydantic_evals.Case]."""
9090
inputs: InputsT
91-
"""The inputs to the task, from [`Case.inputs`][pydantic_evals.Case.inputs]."""
91+
"""The inputs to the task, from [`Case.inputs`][pydantic_evals.dataset.Case.inputs]."""
9292
metadata: MetadataT | None
93-
"""Any metadata associated with the case, from [`Case.metadata`][pydantic_evals.Case.metadata]."""
93+
"""Any metadata associated with the case, from [`Case.metadata`][pydantic_evals.dataset.Case.metadata]."""
9494
expected_output: OutputT | None
95-
"""The expected output of the task, from [`Case.expected_output`][pydantic_evals.Case.expected_output]."""
95+
"""The expected output of the task, from [`Case.expected_output`][pydantic_evals.dataset.Case.expected_output]."""
9696

9797
error_message: str
9898
"""The message of the exception that caused the failure."""

pydantic_graph/pydantic_graph/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def run_sync(
167167
) -> GraphRunResult[StateT, RunEndT]:
168168
"""Synchronously run the graph.
169169
170-
This is a convenience method that wraps [`self.run`][pydantic_graph.Graph.run] with `loop.run_until_complete(...)`.
170+
This is a convenience method that wraps [`self.run`][pydantic_graph.graph.Graph.run] with `loop.run_until_complete(...)`.
171171
You therefore can't use this method inside async code or if there's an active event loop.
172172
173173
Args:

0 commit comments

Comments
 (0)