Skip to content

Commit

Permalink
#77: Small refactor of SplittingInterpreter and utils
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPrit committed Sep 7, 2022
1 parent a0384bc commit 2a0ad1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tickit/adapters/interpreters/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import AnyStr, AsyncIterable, List
from typing import AnyStr, AsyncIterable, Iterable


async def wrap_as_async_iterable(message: AnyStr) -> AsyncIterable[AnyStr]:
Expand All @@ -14,15 +14,15 @@ async def wrap_as_async_iterable(message: AnyStr) -> AsyncIterable[AnyStr]:


async def wrap_messages_as_async_iterable(
messages: List[AnyStr],
messages: Iterable[AnyStr],
) -> AsyncIterable[AnyStr]:
"""Wraps a message in an asynchronous iterable.
Args:
message (AnyStr): A singular message.
message (AnyStr): An iterable containing a number of messages.
Returns:
AsyncIterable[AnyStr]: An asynchronous iterable containing the message.
AsyncIterable[AnyStr]: An asynchronous iterable containing the messages.
"""
for message in messages:
yield message
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ async def handle(
A tuple of the asynchronous iterable of reply messages and a flag
indicating whether an interrupt should be raised by the adapter.
"""
# re.split(...) can contain instances of None - we discard these
individual_messages = [
msg for msg in re.split(self.message_delimiter, message) if msg is not None
]

results = await self._handle_individual_messages(adapter, individual_messages)

(resp, interrupt) = await self._collect_responses(results)

return resp, interrupt
return await self._collect_responses(results)

0 comments on commit 2a0ad1e

Please sign in to comment.