Skip to content

Limitations of the kwargs_to_strings decorator not handling positional arguments #2361

@seisman

Description

@seisman

Here are some limitations of the kwargs_to_strings decorator:

  1. Doesn't work for the default values of parameters:

#2208 (comment)

Please note that we can't use decorator @kwargs_to_strings(offset="sequence") here, because the decorator can only deal with keyword arguments and doesn't work for the default values. I.e., it doesn't work for Figure.timestamp() but works for Figure.timestamp(offset=["-54p", "-54p"]), although offset defaults to ["-54p", "-54p"].

@kwargs_to_strings(offset="sequence")
def timestamp(
    self,
    text=None,
    label=None,
    justification="BL",
    offset=("-54p", "-54p"),
    font="Helvetica",
    timefmt="%Y %b %d %H:%M:%S",
):
  1. Doesn't work if the parameter name is not given
>>> from pygmt import which
>>> # doesn't work
>>> which(["@hotspots.txt", "@earth_relief_01d_g"])
gmtwhich [ERROR]: File ['@hotspots.txt', not found!
gmtwhich [ERROR]: File '@earth_relief_01d_g'] not found!
>>> # works
>>> which(fname=["@hotspots.txt", "@earth_relief_01d_g"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions