Skip to content

Commit

Permalink
None shall not pass args_in_kwargs (GenericMappingTools#1815)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weiji14 authored and Josh Sixsmith committed Dec 21, 2022
1 parent b07b3ac commit 11438a8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 11438a8

Please sign in to comment.