diff --git a/pygmt/src/config.py b/pygmt/src/config.py index 8b95fa8ed28..b1a042c3813 100644 --- a/pygmt/src/config.py +++ b/pygmt/src/config.py @@ -2,6 +2,7 @@ config - Change GMT default settings globally or locally. """ +import warnings from inspect import Parameter, Signature from typing import ClassVar @@ -22,6 +23,12 @@ class config: # noqa: N801 ... Full GMT defaults list at :gmt-docs:`gmt.conf.html`. + + .. note:: + + :gmt-term:`PS_CONVERT` is not supported. + To configure conversion options, please pass parameters to + :meth:`pygmt.Figure.savefig` or :meth:`pygmt.Figure.show` instead. """ # Manually set the __signature__ attribute to enable tab autocompletion @@ -135,7 +142,7 @@ class config: # noqa: N801 "PS_CHAR_ENCODING", "PS_COLOR_MODEL", "PS_COMMENTS", - "PS_CONVERT", + # "PS_CONVERT", # Not supported; use parameters of Figure.savefig/show instead "PS_IMAGE_COMPRESS", "PS_LINE_CAP", "PS_LINE_JOIN", @@ -188,6 +195,16 @@ class config: # noqa: N801 ) def __init__(self, **kwargs): + if "PS_CONVERT" in kwargs: + warnings.warn( + message="Parameter 'PS_CONVERT' is not supported. " + "To configure conversion options, please pass parameters to " + "pygmt.Figure.savefig or pygmt.Figure.show instead.", + category=SyntaxWarning, + stacklevel=2, + ) + kwargs.pop("PS_CONVERT") + # Save values so that we can revert to their initial values self.old_defaults = {} with Session() as lib: diff --git a/pygmt/tests/test_config.py b/pygmt/tests/test_config.py index b946abeaea9..6a8c9bf3529 100644 --- a/pygmt/tests/test_config.py +++ b/pygmt/tests/test_config.py @@ -198,3 +198,20 @@ def test_config_map_tick_pen(): fig.shift_origin(yshift=-3) fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="error") return fig + + +def test_config_ps_convert(): + """ + Test that Parameter 'PS_CONVERT' is not supported. + """ + # Check that PS_CONVERT is removed from the autocomplete list + assert "PS_CONVERT" not in config._keywords + + # Check that a warning is raised when PS_CONVERT is used in config + msg = ( + "Parameter 'PS_CONVERT' is not supported. " + "To configure conversion options, please pass parameters to " + "pygmt.Figure.savefig or pygmt.Figure.show instead." + ) + with pytest.warns(SyntaxWarning, match=msg): + config(PS_CONVERT="C")