Skip to content

Commit 4f4df74

Browse files
committed
bugfix: _select_args should not return [None]
_select_args would return [None] because 'select' was present in req.state but with a value of None. Also runtime check returned values, because the typing of req.args is very lax at the moment.
1 parent cbbdce4 commit 4f4df74

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/pyff/builtins.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,18 +685,26 @@ def load(req: Plumbing.Request, *opts):
685685
req.md.rm.reload(fail_on_error=bool(_opts['fail_on_error']))
686686

687687

688-
def _select_args(req):
688+
def _select_args(req: Plumbing.Request) -> List[str]:
689+
log.debug(f'Select args: {req.args}, state: {req.state}')
689690
args = req.args
690-
if args is None and 'select' in req.state:
691-
args = [req.state.get('select')]
691+
if args is None and req.state.select:
692+
args = [req.state.select]
693+
log.debug(f'Using req.state.select: {args}')
692694
if args is None:
693695
args = req.store.collections()
696+
log.debug(f'Using req.store.collections: {args}')
694697
if args is None or not args:
695698
args = req.store.lookup('entities')
699+
log.debug(f'Using req.store.entities: {args}')
696700
if args is None or not args:
697701
args = []
698702

699-
log.info("selecting using args: %s" % args)
703+
log.info(f'selecting using args: {args}')
704+
705+
for this in args:
706+
if not isinstance(this, str):
707+
raise ValueError(f'Selection resulted in something that is not a string: {this}')
700708

701709
return args
702710

0 commit comments

Comments
 (0)