pydantic / pydantic/pytest-examples
Examples is never formatted correctly
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 178
- Forks
- 25
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 7
Description
This example is never formatted correctly
from typing import Union
from pydantic_ai import RunContext, Tool
from pydantic_ai.tools import ToolDefinition
async def only_if_42(
ctx: RunContext[int], tool_def: ToolDefinition
) -> Union[ToolDefinition, None]:
if ctx.deps == 42:
return tool_def
def hitchhiker(ctx: RunContext[int], answer: str) -> str:
return f'{ctx.deps} {answer}'
hitchhiker = Tool(hitchhiker, prepare=only_if_42)
Because ruff and black disagree.
Black error:
ruff failed:
pydantic_ai_slim/pydantic_ai/tools.py:103:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / from typing import Union
2 | |
3 | | from pydantic_ai import RunContext, Tool
4 | | from pydantic_ai.tools import ToolDefinition
5 | |
6 | | async def only_if_42(
| |_^ I001
7 | ctx: RunContext[int], tool_def: ToolDefinition
8 | ) -> Union[ToolDefinition, None]:
|
= help: Organize imports
Found 1 error.
[*] 1 fixable with the `--fix` option.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the embedded Python example and the reported pydantic_ai_slim/pydantic_ai/tools.py:103:1 location, then run the repository's formatting checks to reproduce the Ruff import-order failure. Identify why the example is transformed into that file and make the formatting tools agree; done means the example passes both formatting checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100