Skip to content

Commit d6628b6

Browse files
authored
TYP: Add type hints to the is_nonstr_iter and args_in_kwargs functions (#3820)
1 parent 0747d5d commit d6628b6

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

pygmt/helpers/utils.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,9 @@ def build_arg_list( # noqa: PLR0912
587587
return gmt_args
588588

589589

590-
def is_nonstr_iter(value):
590+
def is_nonstr_iter(value: Any) -> bool:
591591
"""
592-
Check if the value is not a string but is iterable (list, tuple, array)
592+
Check if the value is iterable (e.g., list, tuple, array) but not a string.
593593
594594
Parameters
595595
----------
@@ -598,12 +598,11 @@ def is_nonstr_iter(value):
598598
599599
Returns
600600
-------
601-
is_iterable : bool
601+
is_iterable
602602
Whether it is a non-string iterable or not.
603603
604604
Examples
605605
--------
606-
607606
>>> is_nonstr_iter("abc")
608607
False
609608
>>> is_nonstr_iter(10)
@@ -662,32 +661,29 @@ def launch_external_viewer(fname: str, waiting: float = 0) -> None:
662661
time.sleep(waiting)
663662

664663

665-
def args_in_kwargs(args, kwargs):
664+
def args_in_kwargs(args: Sequence[str], kwargs: dict[str, Any]) -> bool:
666665
"""
667-
Take a list and a dictionary, and determine if any entries in the list are keys in
668-
the dictionary.
666+
Take a sequence and a dictionary, and determine if any entries in the sequence are
667+
keys in the dictionary.
669668
670-
This function is used to determine if at least one of the required
671-
arguments is passed to raise a GMTInvalidInput Error.
669+
This function is used to determine if at least one of the required arguments is
670+
passed to raise a GMTInvalidInput Error.
672671
673672
Parameters
674673
----------
675-
args : list
676-
List of required arguments, using the GMT short-form aliases.
677-
678-
kwargs : dict
679-
The dictionary of kwargs is the format returned by the _preprocess
680-
function of the BasePlotting class. The keys are the GMT
681-
short-form aliases of the parameters.
674+
args
675+
Sequence of required arguments, using the GMT short-form aliases.
676+
kwargs
677+
The dictionary of GMT options and arguments. The keys are the GMT short-form
678+
aliases of the parameters.
682679
683680
Returns
684681
-------
685682
bool
686-
If one of the required arguments is in ``kwargs``.
683+
Whether one of the required arguments is in ``kwargs``.
687684
688685
Examples
689686
--------
690-
691687
>>> args_in_kwargs(args=["A", "B"], kwargs={"C": "xyz"})
692688
False
693689
>>> args_in_kwargs(args=["A", "B"], kwargs={"B": "af"})

0 commit comments

Comments
 (0)