From 37f31b0f61f187932f82ded7079f3c023246a68b Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Mon, 3 May 2021 16:04:12 +0200 Subject: [PATCH] rewrite data validation to something mypy approves of --- src/pyff/builtins.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pyff/builtins.py b/src/pyff/builtins.py index f5b9abf5..d527f81a 100644 --- a/src/pyff/builtins.py +++ b/src/pyff/builtins.py @@ -687,7 +687,14 @@ def load(req: Plumbing.Request, *opts): def _select_args(req: Plumbing.Request) -> List[str]: log.debug(f'Select args: {req.args}, state: {req.state}') - args = req.args + args: List[str] = [] + + if req.args: + for this in req.args: + if not isinstance(this, str): + raise ValueError(f'Selection not possible with arg that is not a string: {this}') + args += [this] + if args is None and req.state.select: args = [req.state.select] log.debug(f'Using req.state.select: {args}') @@ -702,10 +709,6 @@ def _select_args(req: Plumbing.Request) -> List[str]: log.info(f'selecting using args: {args}') - for this in args: - if not isinstance(this, str): - raise ValueError(f'Selection resulted in something that is not a string: {this}') - return args