Skip to content

Commit

Permalink
bugfix after change from default None to empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikt committed May 3, 2021
1 parent 37f31b0 commit 1763776
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/pyff/api.py
Expand Up @@ -300,7 +300,6 @@ def process_handler(request: Request) -> Response:
)

r = p.process(request.registry.md, state=state, raise_exceptions=True, scheduler=request.registry.scheduler)
log.debug(f'Plumbing process result: {r}')
if r is None:
r = []

Expand Down
24 changes: 15 additions & 9 deletions src/pyff/builtins.py
Expand Up @@ -13,7 +13,7 @@
from copy import deepcopy
from datetime import datetime
from distutils.util import strtobool
from typing import Any, Dict, List, Optional
from typing import Any, Dict, Iterable, List, Optional

import ipaddr
import six
Expand Down Expand Up @@ -274,10 +274,10 @@ def fork(req: Plumbing.Request, *opts):

@deprecated(reason="any pipeline has been replace by other behaviour")
@pipe(name='any')
def _any(lst, d):
def _any(lst: Iterable[Any], d: Any) -> Any:
for x in lst:
if x in d:
if type(d) == dict:
if isinstance(d, dict):
return d[x]
else:
return True
Expand Down Expand Up @@ -695,19 +695,25 @@ def _select_args(req: Plumbing.Request) -> List[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:
if not args and req.state.select:
args = [req.state.select]
log.debug(f'Using req.state.select: {args}')
if args is None:
if not args:
args = req.store.collections()
log.debug(f'Using req.store.collections: {args}')
if args is None or not args:
if not args:
args = req.store.lookup('entities')
log.debug(f'Using req.store.entities: {args}')
if args is None or not args:
if len(args) < 5:
log.debug(f'Using req.store.entities: {args}')
else:
log.debug(f'Using req.store.entities: {args[:4]} (truncated)')
if not args:
args = []

log.info(f'selecting using args: {args}')
if len(args) < 5:
log.info(f'selecting using args: {args}')
else:
log.info(f'selecting using args: {args[:4]} (truncated)')

return args

Expand Down

0 comments on commit 1763776

Please sign in to comment.