GenericMappingTools / pygmt

A Python interface for the Generic Mapping Tools.
https://www.pygmt.org
BSD 3-Clause "New" or "Revised" License
758 stars 220 forks source link

Short- and long-form kwargs can coexist silently #377

Closed liamtoney closed 4 years ago

liamtoney commented 5 years ago

Description of the problem

Python doesn't allow keyword arguments to be repeated. Our current setup does allow for e.g. the following, however:

import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 1, 0, 1], B='+tbar', frame='+tfoo')
fig.show(method='external')

This example produces

ex

silently overriding the B='+tbar' "repeated" argument. I feel like we should raise a SyntaxError in this case, like what Python does for repeated kwargs. I think this would involve modifying the use_alias() decorator, but I'm not totally sure. This addresses the discussion in https://github.com/GenericMappingTools/pygmt/pull/359#discussion_r343539273. If #262 were implemented, this could be a non-issue.

(I'm not sure if this is a bug or a feature request; I chose bug.)

weiji14 commented 5 years ago

Let's mark it down as a bug :laughing: Hopefully our users spot this.