From 95f0c83c72a16dd498b6cf2c8f44e904b5d49707 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 23 Jan 2025 21:03:27 -0500 Subject: [PATCH 1/5] Add rudimentary codespell config --- pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index fdc613b039..29518e815c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -183,3 +183,10 @@ ignore_no_config = true [tool.inline-snapshot.shortcuts] snap-fix=["create", "fix"] snap=["create"] + +[tool.codespell] +# Ref: https://github.com/codespell-project/codespell#using-a-config-file +skip = '.git*,*.svg,*.lock,*.css' +check-hidden = true +# ignore-regex = '' +# ignore-words-list = '' From 5e0f9eaeb6bf64b8d18ae70fc973b8d82a4e5c38 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 23 Jan 2025 21:03:27 -0500 Subject: [PATCH 2/5] Add pre-commit definition for codespell --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 714e9156f7..e990a04963 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,3 +39,11 @@ repos: language: system types: [python] pass_filenames: false + + - repo: https://github.com/codespell-project/codespell + # Configuration for codespell is in pyproject.toml + rev: v2.3.0 + hooks: + - id: codespell + additional_dependencies: + - tomli From 4087707fc318267f16655a1b8b17267aad4d68ec Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 23 Jan 2025 21:04:51 -0500 Subject: [PATCH 3/5] Replace "ans" with "answer" to avoid being close to typo of "and" --- tests/typed_graph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/typed_graph.py b/tests/typed_graph.py index 06ef0b6a55..d0b6a02b7e 100644 --- a/tests/typed_graph.py +++ b/tests/typed_graph.py @@ -109,6 +109,6 @@ def run_g5() -> None: g5.run_sync(A()) # pyright: ignore[reportArgumentType] g5.run_sync(A(), state=MyState(x=1)) # pyright: ignore[reportArgumentType] g5.run_sync(A(), deps=MyDeps(y='y')) # pyright: ignore[reportArgumentType] - ans, history = g5.run_sync(A(), state=MyState(x=1), deps=MyDeps(y='y')) - assert_type(ans, int) + answer, history = g5.run_sync(A(), state=MyState(x=1), deps=MyDeps(y='y')) + assert_type(answer, int) assert_type(history, list[HistoryStep[MyState, int]]) From 8d3d7b07c72dd0f7290defba2c60c19cf5502a73 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 23 Jan 2025 21:08:18 -0500 Subject: [PATCH 4/5] Add a skip for codespell --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 29518e815c..1141cdf776 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -188,5 +188,6 @@ snap=["create"] # Ref: https://github.com/codespell-project/codespell#using-a-config-file skip = '.git*,*.svg,*.lock,*.css' check-hidden = true -# ignore-regex = '' +# Ignore "formatting" like **L**anguage +ignore-regex = '\*\*[A-Z]\*\*[a-z]+\b' # ignore-words-list = '' From 5349963016417441081d908225b5d74ec300c1cb Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 23 Jan 2025 21:08:20 -0500 Subject: [PATCH 5/5] [DATALAD RUNCMD] run codespell throughout fixing few left typos automagically === Do not change lines below === { "chain": [], "cmd": "codespell -w", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ --- docs/graph.md | 2 +- docs/tools.md | 2 +- pydantic_ai_slim/pydantic_ai/models/mistral.py | 2 +- pydantic_ai_slim/pydantic_ai/models/ollama.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/graph.md b/docs/graph.md index d231f6ca3b..74aa4eaf23 100644 --- a/docs/graph.md +++ b/docs/graph.md @@ -450,7 +450,7 @@ class Feedback(BaseNode[State, None, Email]): async def main(): user = User( name='John Doe', - email='john.joe@exmaple.com', + email='john.joe@example.com', interests=['Haskel', 'Lisp', 'Fortran'], ) state = State(user) diff --git a/docs/tools.md b/docs/tools.md index a966a996bd..0f03a07bb2 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -186,7 +186,7 @@ sequenceDiagram ## Registering Function Tools via kwarg -As well as using the decorators, we can register tools via the `tools` argument to the [`Agent` constructor][pydantic_ai.Agent.__init__]. This is useful when you want to re-use tools, and can also give more fine-grained control over the tools. +As well as using the decorators, we can register tools via the `tools` argument to the [`Agent` constructor][pydantic_ai.Agent.__init__]. This is useful when you want to reuse tools, and can also give more fine-grained control over the tools. ```python {title="dice_game_tool_kwarg.py"} import random diff --git a/pydantic_ai_slim/pydantic_ai/models/mistral.py b/pydantic_ai_slim/pydantic_ai/models/mistral.py index 2968ed4e38..90101e0676 100644 --- a/pydantic_ai_slim/pydantic_ai/models/mistral.py +++ b/pydantic_ai_slim/pydantic_ai/models/mistral.py @@ -600,7 +600,7 @@ def _map_content(content: MistralOptionalNullable[MistralContent]) -> str | None elif isinstance(content, str): result = content - # Note: Check len to handle potential mismatch between function calls and responses from the API. (`msg: not the same number of function class and reponses`) + # Note: Check len to handle potential mismatch between function calls and responses from the API. (`msg: not the same number of function class and responses`) if result and len(result) == 0: result = None diff --git a/pydantic_ai_slim/pydantic_ai/models/ollama.py b/pydantic_ai_slim/pydantic_ai/models/ollama.py index 6e167317b8..ae38201676 100644 --- a/pydantic_ai_slim/pydantic_ai/models/ollama.py +++ b/pydantic_ai_slim/pydantic_ai/models/ollama.py @@ -80,7 +80,7 @@ def __init__( ): """Initialize an Ollama model. - Ollama has built-in compatability for the OpenAI chat completions API ([source](https://ollama.com/blog/openai-compatibility)), so we reuse the + Ollama has built-in compatibility for the OpenAI chat completions API ([source](https://ollama.com/blog/openai-compatibility)), so we reuse the [`OpenAIModel`][pydantic_ai.models.openai.OpenAIModel] here. Args: