Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples is never formatted correctly #46

Open
samuelcolvin opened this issue Dec 8, 2024 · 0 comments
Open

Examples is never formatted correctly #46

samuelcolvin opened this issue Dec 8, 2024 · 0 comments

Comments

@samuelcolvin
Copy link
Member

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant