From 55d5efdb965b7b6cd1b73892a348526f1ddc8d10 Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Mon, 27 Jul 2026 13:42:19 +0300 Subject: [PATCH] chore: adopt ruff 0.16.0 ruff 0.16.0 stabilized CPY001 (missing-copyright-notice) out of preview, so `select = ["ALL"]` now picks it up. Ignore it, matching modern-di. 0.16.0 also formats Python code blocks inside Markdown; reformat the 7 affected file(s). No .py file changed. --- README.md | 6 ++++-- docs/usage/basic.md | 4 +++- docs/usage/publisher.md | 5 +++-- docs/usage/router.md | 8 ++++---- docs/usage/subscriber.md | 12 ++++++------ .../2026-06-03.01-faststream-0.7-migration.md | 2 ++ .../2026-06-29.01-python-3.11-3.12-support.md | 1 + pyproject.toml | 1 + 8 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e04937b..71affcf 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,12 @@ client = Redis.from_url("redis://localhost:6379") broker = TimersBroker(client) app = FastStream(broker) + @broker.subscriber("invoices") async def handle_invoice(invoice_id: str) -> None: print(f"Invoice {invoice_id} is due!") + @app.after_startup async def schedule() -> None: await broker.publish( @@ -107,13 +109,13 @@ Inside the handler: ```python from faststream import Context + @broker.subscriber("orders") async def handle( body: dict, correlation_id: str = Context("message.correlation_id"), tenant: str = Context("message.headers.x-tenant"), -) -> None: - ... +) -> None: ... ``` ## Connection ownership diff --git a/docs/usage/basic.md b/docs/usage/basic.md index d70671b..6af0f81 100644 --- a/docs/usage/basic.md +++ b/docs/usage/basic.md @@ -29,6 +29,7 @@ Use `broker.publish()` with `activate_in` (relative delay) or `activate_at` (abs ```python from datetime import UTC, datetime, timedelta + @app.after_startup async def schedule_reminder() -> None: # Relative — fire 24 hours from now @@ -143,7 +144,8 @@ pending = await broker.get_pending_timers("invoices") # Only those due in the next hour soon = await broker.get_pending_timers( - "invoices", before=datetime.now(tz=UTC) + timedelta(hours=1), + "invoices", + before=datetime.now(tz=UTC) + timedelta(hours=1), ) # Wipe a topic's queue (e.g., during a maintenance reset) diff --git a/docs/usage/publisher.md b/docs/usage/publisher.md index 4f07fd1..b55d695 100644 --- a/docs/usage/publisher.md +++ b/docs/usage/publisher.md @@ -72,13 +72,14 @@ from faststream.message import StreamMessage pub = broker.publisher("orders") + @broker.subscriber("orders") async def handle( body: dict, correlation_id: str = Context("message.correlation_id"), tenant: str = Context("message.headers.x-tenant"), -) -> None: - ... +) -> None: ... + await pub.publish( {"order_id": 42}, diff --git a/docs/usage/router.md b/docs/usage/router.md index 5201603..72502ad 100644 --- a/docs/usage/router.md +++ b/docs/usage/router.md @@ -91,10 +91,10 @@ You can configure polling behaviour per subscriber: ```python @router.subscriber( "high-priority", - polling_interval=0.01, # poll every 10ms when the queue has work - max_polling_interval=0.5, # cap idle-backoff at 500ms (default 5s) - max_concurrent=20, # up to 20 handlers may run in parallel - lease_ttl=60, # hold lease for up to 60 seconds + polling_interval=0.01, # poll every 10ms when the queue has work + max_polling_interval=0.5, # cap idle-backoff at 500ms (default 5s) + max_concurrent=20, # up to 20 handlers may run in parallel + lease_ttl=60, # hold lease for up to 60 seconds ) async def handle_urgent(message: str) -> None: ... ``` diff --git a/docs/usage/subscriber.md b/docs/usage/subscriber.md index 3b45994..dd1d159 100644 --- a/docs/usage/subscriber.md +++ b/docs/usage/subscriber.md @@ -73,10 +73,10 @@ Configure polling behaviour per subscriber: ```python @broker.subscriber( "high-priority", - polling_interval=0.01, # poll every 10ms when busy - max_polling_interval=0.5, # never sleep longer than 500ms when idle - max_concurrent=20, # up to 20 handlers may run in parallel - lease_ttl=60, # hold lease for up to 60 seconds + polling_interval=0.01, # poll every 10ms when busy + max_polling_interval=0.5, # never sleep longer than 500ms when idle + max_concurrent=20, # up to 20 handlers may run in parallel + lease_ttl=60, # hold lease for up to 60 seconds ) async def handle_urgent(body: str) -> None: ... ``` @@ -113,7 +113,7 @@ async def handle_invoice( process(body) await msg.ack() except TransientError: - await msg.nack() # retry later + await msg.nack() # retry later except PermanentError: - await msg.reject() # discard permanently + await msg.reject() # discard permanently ``` diff --git a/planning/changes/2026-06-03.01-faststream-0.7-migration.md b/planning/changes/2026-06-03.01-faststream-0.7-migration.md index 7349bc0..2435f93 100644 --- a/planning/changes/2026-06-03.01-faststream-0.7-migration.md +++ b/planning/changes/2026-06-03.01-faststream-0.7-migration.md @@ -207,6 +207,7 @@ _parser: AsyncCallable _decoder: AsyncCallable codec: CodecProto # NEW in 0.7 + # faststream/_internal/endpoint/subscriber/usecase.py — add_call signature def add_call( self, @@ -217,6 +218,7 @@ def add_call( codec_: Optional[CodecProto] = None, # NEW; timers passes nothing ) -> Self: ... + # faststream/_internal/testing/broker.py — create_publisher_fake_subscriber @abstractmethod def create_publisher_fake_subscriber( diff --git a/planning/changes/2026-06-29.01-python-3.11-3.12-support.md b/planning/changes/2026-06-29.01-python-3.11-3.12-support.md index f564865..2245d65 100644 --- a/planning/changes/2026-06-29.01-python-3.11-3.12-support.md +++ b/planning/changes/2026-06-29.01-python-3.11-3.12-support.md @@ -69,6 +69,7 @@ Alternatives rejected: becomes ```python from typing_extensions import TypeAlias + RedisClient: TypeAlias = "Redis[bytes] | Redis[str]" ``` (Comment block above the alias is preserved.) diff --git a/pyproject.toml b/pyproject.toml index 83c728c..e39a339 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,7 @@ ignore = [ "ISC001", # flake8-implicit-str-concat "G004", # Logging statement uses f-string "ANN", + "CPY001", # no per-file copyright header ] isort.lines-after-imports = 2 isort.no-lines-before = ["standard-library", "local-folder"]