diff --git a/doc/conf.py b/doc/conf.py index 34abad8b91d..82a92c43933 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -28,6 +28,9 @@ "sphinx_gallery.gen_gallery", ] +# Autodoc configurations +autodoc_typehints = "description" + # Autosummary pages will be generated by sphinx-autogen instead of sphinx-build autosummary_generate = [] diff --git a/pygmt/datasets/earth_relief.py b/pygmt/datasets/earth_relief.py index 62b6bf8cb47..4a86163ad34 100644 --- a/pygmt/datasets/earth_relief.py +++ b/pygmt/datasets/earth_relief.py @@ -4,6 +4,9 @@ The grids are available in various resolutions. """ +from collections.abc import Sequence +from typing import Literal, Union + from pygmt.datasets.load_remote_dataset import _load_remote_dataset from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import kwargs_to_strings @@ -13,11 +16,11 @@ @kwargs_to_strings(region="sequence") def load_earth_relief( - resolution="01d", - region=None, - registration=None, - data_source="igpp", - use_srtm=False, + resolution: str = "01d", + region: Union[str, Sequence, None] = None, + registration: Literal["gridline", "pixel", None] = None, + data_source: Literal["igpp", "gebco", "gebcosi", "synbath"] = "igpp", + use_srtm: bool = False, ): r""" Load the Earth relief datasets (topography and bathymetry) in various diff --git a/pygmt/src/basemap.py b/pygmt/src/basemap.py index 25ea7cb408e..8854adb4138 100644 --- a/pygmt/src/basemap.py +++ b/pygmt/src/basemap.py @@ -2,10 +2,29 @@ basemap - Plot base maps and frames for the figure. """ +from typing import Any, TypedDict, Unpack + from pygmt.clib import Session from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias +class Parameters(TypedDict): + region: Any + projection: Any + zscale: Any + zsize: Any + frame: Any + map_scale: Any + box: Any + rose: Any + compass: Any + verbose: bool + panel: Any + coltypes: Any + perspective: Any + transparency: Any + + @fmt_docstring @use_alias( R="region", @@ -24,7 +43,7 @@ t="transparency", ) @kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence") -def basemap(self, **kwargs): +def basemap(self, **kwargs: Unpack[Parameters]): r""" Plot base maps and frames for the figure. diff --git a/pygmt/src/coast.py b/pygmt/src/coast.py index 00e80d09d7b..2801002f67b 100644 --- a/pygmt/src/coast.py +++ b/pygmt/src/coast.py @@ -1,6 +1,7 @@ """ coast - Plot land and water. """ +from typing import Any, Literal from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput @@ -36,7 +37,26 @@ t="transparency", ) @kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence") -def coast(self, **kwargs): +def coast( + self, + region: Any = None, + projection: Any = None, + area_thresh: Any = None, + frame: Any = None, + resolution: Literal["f", "h", "i", "l", "c", "a", None] = None, + land: Any = None, + water: Any = None, + rivers: Any = None, + borders: Any = None, + lakes: Any = None, + map_scale: Any = None, + dcw: Any = None, + shorelines: Any = None, + perspective: Any = None, + transparency: Any = None, + verbose: Any = None, + **kwargs, +): r""" Plot continents, shorelines, rivers, and borders on maps. diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 5cd748f3054..307def683ca 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -1,6 +1,8 @@ """ text - Plot text on a figure. """ +from typing import TypedDict + import numpy as np from pygmt.clib import Session from pygmt.exceptions import GMTInvalidInput @@ -15,6 +17,12 @@ ) +class Paragraph(TypedDict): + linewidth: str + width: str + justify: str + + @fmt_docstring @use_alias( R="region", @@ -23,6 +31,7 @@ C="clearance", D="offset", G="fill", + M="paragraph", N="no_clip", V="verbose", W="pen", @@ -52,6 +61,7 @@ def text_( # noqa: PLR0912 angle=None, font=None, justify=None, + paragraph: Paragraph = None, **kwargs, ): r"""