@override
def visit(
self,
*,
sub: "LogicSubscriber",
channel: str | None = None,
list: str | None = None,
stream: str | None = None,
) -> str | None:
if channel is None or not isinstance(sub, ChannelSubscriber):
return None
sub_channel = sub.channel
if (
sub_channel.pattern
and bool(
re.match(
# Escaped wholesale and then opened back up at the wildcard,
# the way `REDIS_ADDRESS_SYNTAX` does it: a Broker address may
# hold a literal brace, and `{2}` left bare is a quantifier.
re.escape(sub_channel.name).replace(r"\*", ".*"),
channel or "",
),
)
) or channel == sub_channel.name:
return channel
return None