github ag2ai/faststream 0.7.1
v0.7.1

3 hours ago

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")

Full Changelog: 0.7.0...0.7.1

Don't miss a new faststream release

NewReleases is sending notifications on new releases.