Skip to content

chore: migrate to faststream 0.7 (drop 0.6 support)#28

Merged
lesnik512 merged 1 commit into
mainfrom
chore/faststream-0.7-migration
Jun 3, 2026
Merged

chore: migrate to faststream 0.7 (drop 0.6 support)#28
lesnik512 merged 1 commit into
mainfrom
chore/faststream-0.7-migration

Conversation

@lesnik512

@lesnik512 lesnik512 commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Bumps faststream[kafka] from >=0.6,<0.7 to >=0.7,<0.8.
  • Drops 0.6 support entirely — single code path, no compat shim.
  • Pure compat migration — no new 0.7 features adopted.

Break points

  • TestKafkaBroker.__init__ became variadic in 0.7. __aenter__ now returns Broker | list[Broker] instead of Broker. All 23 async with TestKafkaBroker(broker) as test_broker: sites in tests/ were affected.
    • Fix: new fake_test_broker helper in tests/mocks.py wraps TestKafkaBroker and narrows the single-broker case to KafkaBroker. 23 callsites switched to use the helper.
  • BaseMiddleware.consume_scope signature in 0.7: (self, call_next: AsyncFuncAny, msg: StreamMessage[AnyMsg]) -> Any. The override in faststream_concurrent_aiokafka/middleware.py narrows msg to KafkaAckableMessage (Liskov violation). The 0.6-era # ty: ignore[invalid-method-override] continues to suppress this — the narrowing is intentional documentation of the MANUAL-ack design center. Added a 3-line "why" comment above the ignore.
  • No other 0.7 breaks surfaced. FakeConsumer class name unchanged, all 5 public import paths (BaseMiddleware, ContextRepo, ConsumerRecord, TopicPartition, KafkaBroker, KafkaRouter, TestKafkaBroker, KafkaAckableMessage, AckPolicy.MANUAL, AsgiFastStream) still resolve. No Producer/TestBroker/Registrator subclass to touch.

Test plan

  • just lint passes (ruff + ty)
  • just test passes at 100% coverage on Python 3.13 locally
  • CI matrix (3.11, 3.12, 3.13, 3.14) passes at 100% coverage
  • fake_test_broker helper is the sole new public test surface; lives next to existing patched_message in tests/mocks.py
  • Public import surface exits 0: python -c "from faststream_concurrent_aiokafka import KafkaConcurrentProcessingMiddleware, initialize_concurrent_processing, stop_concurrent_processing, is_kafka_handler_healthy, ConsumerRebalanceListener"

- pyproject.toml: faststream[kafka] >=0.6,<0.7 -> >=0.7,<0.8. Drops 0.6
  support entirely; users on 0.6 stay on previously-released wheels.

Unanticipated 0.7 break — TestKafkaBroker.__init__ became variadic
(*brokers: Broker), and __aenter__ now returns Broker | list[Broker].
This made ty flag all 23 `async with TestKafkaBroker(broker) as test_broker:`
sites in tests/ as Liskov violations.

- tests/mocks.py: new fake_test_broker async-with helper that wraps
  TestKafkaBroker and narrows the single-broker case to KafkaBroker.
  Mirrors the existing patched_message helper's shape.
- tests/test_healthcheck.py: 4 callsites switched to fake_test_broker.
- tests/test_middleware.py: 19 callsites switched to fake_test_broker.
- faststream_concurrent_aiokafka/middleware.py: added a 3-line "why"
  comment to consume_scope's existing # ty: ignore[invalid-method-override].
  0.7's BaseMiddleware.consume_scope is typed (call_next: AsyncFuncAny,
  msg: StreamMessage[AnyMsg]); the override's KafkaAckableMessage
  narrowing remains intentional documentation of the MANUAL-ack design
  center, and ty flags the narrowing as a Liskov violation that the
  ignore comment continues to suppress.

No new 0.7 features adopted (no broker-level AckPolicy default,
no multi-broker, no RedisClusterBroker analog).

Local verification: `just lint` clean; `just test` 111 passed at 100%
coverage on Python 3.13. CI matrix (3.11/3.12/3.13/3.14) will be the
final gate on the 3.11 coverage quirk PR1 already addressed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 self-assigned this Jun 3, 2026
@lesnik512 lesnik512 merged commit 7b26f72 into main Jun 3, 2026
5 checks passed
@lesnik512 lesnik512 deleted the chore/faststream-0.7-migration branch June 3, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant