None shall not pass args_in_kwargs
Fixes bug in `args_in_kwargs` function whereby `None` values
are allowed, when actually, we want to drop the `None`.
* Add failing test for when param=0
* Check that argument is not None or False
@@ -306,5 +306,23 @@ def args_in_kwargs(args, kwargs):
--------
bool
If one of the required arguments is in ``kwargs``.
+
+ Examples
+ --------
+
+ >>> args_in_kwargs(args=["A", "B"], kwargs={"C": "xyz"})
+ False
+ >>> args_in_kwargs(args=["A", "B"], kwargs={"B": "af"})
+ True
+ >>> args_in_kwargs(args=["A", "B"], kwargs={"B": None})
+ False
+ >>> args_in_kwargs(args=["A", "B"], kwargs={"B": True})
+ True
+ >>> args_in_kwargs(args=["A", "B"], kwargs={"B": False})
+ False
+ >>> args_in_kwargs(args=["A", "B"], kwargs={"B": 0})
+ True
"""
- return any(arg in kwargs for arg in args)
+ return any(
+ kwargs.get(arg) is not None and kwargs.get(arg) is not False for arg in args
+ )
