diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index 27c6f28db90..0fcd61d6673 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -11,7 +11,8 @@ import sys import time import webbrowser -from collections.abc import Iterable +from collections.abc import Iterable, Sequence +from typing import Any import xarray as xr from pygmt.exceptions import GMTInvalidInput @@ -320,9 +321,9 @@ def non_ascii_to_octal(argstr): def build_arg_list( - kwdict: dict, - confdict: dict | None = None, - infile: str | pathlib.PurePath | list[str | pathlib.PurePath] | None = None, + kwdict: dict[str, Any], + confdict: dict[str, str] | None = None, + infile: str | pathlib.PurePath | Sequence[str | pathlib.PurePath] | None = None, outfile: str | pathlib.PurePath | None = None, ) -> list[str]: r""" @@ -332,8 +333,8 @@ def build_arg_list( representation using the ``kwargs_to_strings`` decorator. The only exceptions are ``True``, ``False`` and ``None``. - Any lists or tuples left will be interpreted as multiple entries for the same - command line option. For example, the kwargs entry ``"B": ["xa", "yaf"]`` will be + Any remaining lists or tuples will be interpreted as multiple entries for the same + parameter. For example, the kwargs entry ``"B": ["xa", "yaf"]`` will be converted to ``["-Bxa", "-Byaf"]``. Parameters @@ -398,7 +399,7 @@ def build_arg_list( for key, value in kwdict.items(): if len(key) > 2: # Raise an exception for unrecognized options raise GMTInvalidInput(f"Unrecognized parameter '{key}'.") - if value is None or value is False: # Exclude arguments that are None and False + if value is None or value is False: # Exclude arguments that are None or False pass elif value is True: gmt_args.append(f"-{key}") @@ -417,7 +418,7 @@ def build_arg_list( else: gmt_args = [str(_file) for _file in infile] + gmt_args if outfile: - gmt_args.append("->" + str(outfile)) + gmt_args.append(f"->{outfile}") return gmt_args