Skip to content

Commit

Permalink
#74 Add cast of message type in command interpreter
Browse files Browse the repository at this point in the history
Co-authored-by: Garry O'Donnell <garry.o'[email protected]>
  • Loading branch information
abbiemery and garryod committed Aug 1, 2022
1 parent 215582f commit 24c79a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tickit/adapters/interpreters/command/command_interpreter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import abstractmethod
from inspect import getmembers
from typing import AnyStr, AsyncIterable, Optional, Sequence, Tuple
from typing import AnyStr, AsyncIterable, Optional, Sequence, Tuple, get_type_hints

from tickit.core.adapter import Adapter, Interpreter
from tickit.utils.compat.typing_compat import Protocol, runtime_checkable
Expand Down Expand Up @@ -90,6 +90,10 @@ async def handle(
args = command.parse(message)
if args is None:
continue
args = (
argtype(arg)
for arg, argtype in zip(args, get_type_hints(method).values())
)
resp = await method(*args)
if not isinstance(resp, AsyncIterable):
resp = CommandInterpreter._wrap(resp)
Expand Down

0 comments on commit 24c79a4

Please sign in to comment.