From 3850cca37a1aedbcaec11b63a7571b9925b72e34 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Wed, 29 Jul 2026 15:09:45 +0200 Subject: [PATCH 1/2] chore: Enable Ruff formatting of Python code blocks in Markdown --- README.md | 20 ++++++++++++-------- docs/04_upgrading/upgrading_to_v3.md | 13 +++++++++---- docs/04_upgrading/upgrading_to_v4.md | 8 ++++++-- pyproject.toml | 12 +++++++++++- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 86a99b70..71a30680 100644 --- a/README.md +++ b/README.md @@ -154,10 +154,12 @@ async def main() -> None: soup = BeautifulSoup(response.content, 'html.parser') # Push the extracted data to the default dataset. - await Actor.push_data({ - 'url': request.url, - 'title': soup.title.string if soup.title else None, - }) + await Actor.push_data( + { + 'url': request.url, + 'title': soup.title.string if soup.title else None, + } + ) # Mark the request as handled so it is not processed again. await request_queue.mark_request_as_handled(request) @@ -183,10 +185,12 @@ async def main() -> None: @crawler.router.default_handler async def handler(context: PlaywrightCrawlingContext) -> None: Actor.log.info(f'Scraping {context.request.url} ...') - await context.push_data({ - 'url': context.request.url, - 'title': await context.page.title(), - }) + await context.push_data( + { + 'url': context.request.url, + 'title': await context.page.title(), + } + ) # Follow links found on the page. await context.enqueue_links() diff --git a/docs/04_upgrading/upgrading_to_v3.md b/docs/04_upgrading/upgrading_to_v3.md index 57c29a1a..c7f780a3 100644 --- a/docs/04_upgrading/upgrading_to_v3.md +++ b/docs/04_upgrading/upgrading_to_v3.md @@ -96,6 +96,7 @@ from crawlee.configuration import Configuration from crawlee.events import LocalEventManager from apify import Actor + async def main(): async with Actor(): @@ -125,15 +126,19 @@ Apify SDK v3.0 also reworks how storage clients are configured, giving you expli ```python from crawlee import service_locator -from apify.storage_clients import ApifyStorageClient, SmartApifyStorageClient, MemoryStorageClient +from apify.storage_clients import ( + ApifyStorageClient, + SmartApifyStorageClient, + MemoryStorageClient, +) from apify import Actor async def main(): service_locator.set_storage_client( SmartApifyStorageClient( - cloud_storage_client=ApifyStorageClient(request_queue_access="single"), - local_storage_client=MemoryStorageClient() + cloud_storage_client=ApifyStorageClient(request_queue_access='single'), + local_storage_client=MemoryStorageClient(), ) ) async with Actor: @@ -158,7 +163,7 @@ async def main(): # Full client that supports multiple consumers of the Apify Request Queue service_locator.set_storage_client( SmartApifyStorageClient( - cloud_storage_client=ApifyStorageClient(request_queue_access="shared"), + cloud_storage_client=ApifyStorageClient(request_queue_access='shared'), ) ) async with Actor: diff --git a/docs/04_upgrading/upgrading_to_v4.md b/docs/04_upgrading/upgrading_to_v4.md index 2f7dc725..8251283a 100644 --- a/docs/04_upgrading/upgrading_to_v4.md +++ b/docs/04_upgrading/upgrading_to_v4.md @@ -227,11 +227,15 @@ Secondary parameters on several client methods can no longer be passed positiona ```python # Before (v3) -await client.key_value_store('my-store').set_record('my-key', {'data': 1}, 'application/json') +await client.key_value_store('my-store').set_record( + 'my-key', {'data': 1}, 'application/json' +) await client.run('my-run').charge('my-event', 5) # After (v4) -await client.key_value_store('my-store').set_record('my-key', {'data': 1}, content_type='application/json') +await client.key_value_store('my-store').set_record( + 'my-key', {'data': 1}, content_type='application/json' +) await client.run('my-run').charge('my-event', count=5) ``` diff --git a/pyproject.toml b/pyproject.toml index 607778bd..a6bc2657 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,10 +106,20 @@ allow-direct-references = true [tool.ruff] line-length = 120 -include = ["src/**/*.py", "tests/**/*.py", "docs/**/*.py", "website/**/*.py"] +include = [ + "src/**/*.py", + "tests/**/*.py", + "docs/**/*.py", + "website/**/*.py", + # Ruff formats Python code blocks embedded in Markdown files. + "**/*.md", + "**/*.mdx", +] exclude = [ "website/versioned_docs/**", ] +# MDX is Markdown; without this mapping Ruff would try to parse `.mdx` files as Python. +extension = { mdx = "markdown" } [tool.ruff.lint] select = ["ALL"] From 2d2af6bfed4696309141750a54e196bf30834212 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Wed, 29 Jul 2026 15:12:10 +0200 Subject: [PATCH 2/2] chore: Simplify Ruff include patterns to a single Python glob --- pyproject.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a6bc2657..f934781c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,10 +107,7 @@ allow-direct-references = true [tool.ruff] line-length = 120 include = [ - "src/**/*.py", - "tests/**/*.py", - "docs/**/*.py", - "website/**/*.py", + "**/*.py", # Ruff formats Python code blocks embedded in Markdown files. "**/*.md", "**/*.mdx",