From d055f9b3c6064f346f07da6606356ed9063a6820 Mon Sep 17 00:00:00 2001 From: William Schmitt Date: Mon, 16 Nov 2026 13:25:10 -0800 Subject: [PATCH] docs(readme): fix quickstart code fence and timeout snippet import The quickstart closed its ```python fence right after `sessions.create` (README.md:43), so `def run(...)` and the `__main__` guard rendered as Markdown, and the stray ``` before "## Examples" (README.md:67) opened a new fence that swallowed the Examples section up to the ```bash block. Removing the early closer makes the whole quickstart one block and turns the later ``` back into its closer. The timeout snippet calls `httpx.Timeout(...)` without importing httpx. A ruff F821 pass over every README python block showed that as the only undefined name in a standalone snippet. The rest (`client`, `response`, `DefaultHttpxClient` in a `with_options` one-liner) are continuation snippets by design, which is why the new test checks fence structure only and doesn't lint names. tests/test_readme.py asserts fences pair up as labelled-opener/bare-closer. It fails on origin/main and passes after. Verified live: extracted the fixed quickstart block and ran it as-is (screenshot path redirected) against api.dev.browserbase.com with Playwright; it printed "Done!" and the session was released. Not fixed here (separate): the install line `pip install '--pre browserbase'` quotes both tokens as one argument. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- tests/test_readme.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/test_readme.py diff --git a/README.md b/README.md index e792391c..cfcf364d 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ client = Browserbase( session = client.sessions.create( project_id=BROWSERBASE_PROJECT_ID, ) -``` def run(playwright: Playwright) -> None: @@ -301,6 +300,7 @@ By default requests time out after 1 minute. You can configure this with a `time which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object: ```python +import httpx from browserbase import Browserbase # Configure the default for all requests: diff --git a/tests/test_readme.py b/tests/test_readme.py new file mode 100644 index 00000000..89dbc18d --- /dev/null +++ b/tests/test_readme.py @@ -0,0 +1,7 @@ +import re +from pathlib import Path + + +def test_readme_code_fences_are_balanced() -> None: + fences = re.findall(r"^```(.*)$", (Path(__file__).parent.parent / "README.md").read_text(), re.M) + assert fences[1::2] == [""] * (len(fences) // 2) and all(fences[::2])