-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Re-add clai --help output to clai README
#3766
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
Changes from 5 commits
62985e8
6bc6beb
7ff0c27
90a0a64
caa8b1c
97423e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import os | ||
| import re | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from pydantic_ai._cli import cli | ||
|
|
||
|
|
||
| @pytest.mark.skipif(sys.version_info >= (3, 13), reason='slightly different output with 3.13') | ||
| def test_cli_help(capfd: pytest.CaptureFixture[str]): | ||
| """Check README.md help output matches `clai --help`.""" | ||
| os.environ['COLUMNS'] = '150' | ||
| with pytest.raises(SystemExit): | ||
| cli(['--help'], prog_name='clai') | ||
|
|
||
| help_output = capfd.readouterr().out.strip() | ||
| # TODO change when we reach v1 | ||
| help_output = re.sub(r'(Pydantic AI CLI v).+', r'\1...', help_output) | ||
|
|
||
| this_dir = Path(__file__).parent | ||
| readme = this_dir / 'README.md' | ||
| content = readme.read_text(encoding='utf-8') | ||
|
|
||
| new_content, count = re.subn('^(## Help\n+```).+?```', rf'\1\n{help_output}\n```', content, flags=re.M | re.S) | ||
| assert count, 'help section not found' | ||
| if new_content != content: | ||
| readme.write_text(new_content, encoding='utf-8') | ||
| pytest.fail('`clai --help` output changed.') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,7 @@ MCP also offers [stdio transport](https://spec.modelcontextprotocol.io/specifica | |
|
|
||
| In this example [mcp-run-python](https://github.com/pydantic/mcp-run-python) is used as the MCP server. | ||
|
|
||
| ```python {title="mcp_stdio_client.py"} | ||
| ```python {title="mcp_stdio_client.py" test="skip"} | ||
|
||
| from pydantic_ai import Agent | ||
| from pydantic_ai.mcp import MCPServerStdio | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.