Skip to content

Commit ddd85bc

Browse files
authored
actualy added type converting for annotations
1 parent b67807b commit ddd85bc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

actioneer/action.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ def __init__(self, func, aliases: List[str] = [], *,
1010
options: Dict[str, Callable] = {},
1111
options_aliases: Dict[str, str] = {}, flags: List[str] = [],
1212
flags_aliases: Dict[str, str] = {}, performer=None):
13+
1314
self.subs = {}
1415
self.name = func.__name__
1516
self.func = func
1617
self.aliases = aliases
17-
self.casts = [self.make_cast(param)
18+
self.casts = [self.get_cast(param)
1819
for param in signature(func).parameters.values()
1920
if param.kind == Parameter.VAR_POSITIONAL]
2021
self.options = options
@@ -29,9 +30,12 @@ def __init__(self, func, aliases: List[str] = [], *,
2930
bool: bool_from_str
3031
}
3132

32-
def make_cast(self, param):
33+
def get_cast(self, param):
3334
return self.overrides.get(param, param)
3435

36+
def make_cast(self, args):
37+
return [cast(arg) for cast, arg in zip(args, self.casts)]
38+
3539
def invoke(self, args: List[str] = [], ctx: List[Any] = []):
3640
ctx = {type(a): a for a in ctx}
3741
sub = self.subs.get(args[0])
@@ -43,6 +47,7 @@ def invoke(self, args: List[str] = [], ctx: List[Any] = []):
4347
if v.kind == Parameter.KEYWORD_ONLY}
4448

4549
ctxs = {name: ctx[value] for name, value in name_annots.items()}
50+
args =
4651
self.func(*args, **ctxs)
4752
except Exception as e:
4853
if self.error_handler:

0 commit comments

Comments
 (0)