Skip to content
Snippets Groups Projects
Commit 634f4dae authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

small refactor

parent 1b7bdb83
No related branches found
No related tags found
No related merge requests found
......@@ -186,7 +186,7 @@ def has_keys(keys: tp.List[str]):
def short_none(clb: tp.Union[Expression, tp.Callable[[T], U]]) -> tp.Callable[
[tp.Optional[T]], tp.Optional[U]]:
[tp.Optional[T]], tp.Optional[U]]:
"""
Accept a callable. Return a callable that executes it only if passed a no-None arg,
and returns its result. If passed a None, return a None
......
......@@ -5,7 +5,7 @@ def p_all(*args: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any], bool]:
"""
Make a predicate returning True if all specified predicates return True
"""
def predicate(v):
def predicate(v) -> bool:
return all(arg(v) for arg in args)
return predicate
......@@ -14,7 +14,7 @@ def p_any(*args: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any], bool]:
"""
Make a predicate returning True if any of specified predicates return True
"""
def predicate(v):
def predicate(v) -> bool:
return any(arg(v) for arg in args)
return predicate
......@@ -23,7 +23,7 @@ def attribute(attr: str, p: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any]
"""
Make predicate p refer to attribute of the object passed to it.
"""
def predicate(v):
def predicate(v) -> bool:
return p(getattr(v, attr))
return predicate
......@@ -34,7 +34,7 @@ def item(i, p: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any], bool]:
i doesn't have to be an integer, it will be passed to __getitem__
"""
def predicate(v):
def predicate(v) -> bool:
return p(v[i])
return predicate
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment