What's Changed
TestBroker.aenter was typed to return Broker | list[Broker]. That union is wrong for both usage shapes: mypy rejects .publish() on the single-broker result (the list arm has no such method) and rejects unpacking the multi-broker result (the Broker arm is not iterable).
# Before — both lines fail under `mypy`:
async with TestKafkaBroker(KafkaBroker()) as br:
await br.publish(None, "test")
# error: Item "list[KafkaBroker]" of "KafkaBroker | list[KafkaBroker]" has no attribute "publish" [union-attr]
async with TestKafkaBroker(KafkaBroker(), KafkaBroker()) as (br1, br2):
# error: "KafkaBroker" object is not iterable [misc]
...
# After — mypy infers the precise type:
async with TestKafkaBroker(KafkaBroker()) as br:
reveal_type(br) # KafkaBroker
await br.publish(None, "test")
async with TestKafkaBroker(KafkaBroker(), KafkaBroker()) as (br1, br2):
reveal_type(br1) # tuple[KafkaBroker, ...] -> KafkaBroker
await br1.publish(None, "test")
await br2.publish(None, "test")- fix(testing): type TestBroker context result via init overloads by @Lancetnik in #2903
- fix(docs): export *ParserType aliases at runtime by @Lancetnik in #2898
- docs: Clarify FastStream description by @borisalekseev in #2901
Full Changelog: 0.7.0...0.7.1