Examples is never formatted correctly
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
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.
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.
- Dominant language
- Python
- Stars
- 181
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from pydantic/pytest-examples
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pydantic/pytest-examples#87 ·
-
Clean up NeededPossibly taken @Danipulok claimed this 73 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pydantic/pytest-examples#72 · 5 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
pydantic/pytest-examples#82 ·
-
Feature requrest [I can do it myself if allowed]: Allow configuration of `pytest-examples` from `pyproject.toml`Possibly taken @Danipulok claimed this 38 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 64/100
pydantic/pytest-examples#73 · 4 comments ·
-
target_versions are out of datePossibly taken @stevenh claimed this 507 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
pydantic/pytest-examples#63 · 1 comment ·
All issues in pydantic/pytest-examples
Similar issues
-
Email validation accepts a trailing newlinePossibly taken @marcello-pichini claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dbt-labs/spark-utils#51 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug frontend
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vendrabuck/HERD#1419 ·
Maintainers usually reply within 1 day