Skip to content

Commit 318a8c4

Browse files
authored
Add typing hints for the returned value of load_xxx functions (#3329)
1 parent a26b33b commit 318a8c4

15 files changed

+42
-27
lines changed

pygmt/datasets/earth_age.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_earth_age"]
@@ -19,7 +20,7 @@ def load_earth_age(
1920
] = "01d",
2021
region: Sequence[float] | str | None = None,
2122
registration: Literal["gridline", "pixel"] = "gridline",
22-
):
23+
) -> xr.DataArray:
2324
r"""
2425
Load the Earth seafloor crustal age dataset in various resolutions.
2526
@@ -65,7 +66,7 @@ def load_earth_age(
6566
6667
Returns
6768
-------
68-
grid : :class:`xarray.DataArray`
69+
grid
6970
The Earth seafloor crustal age grid. Coordinates are latitude and
7071
longitude in degrees. Age is in millions of years (Myr).
7172

pygmt/datasets/earth_free_air_anomaly.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_earth_free_air_anomaly"]
@@ -19,7 +20,7 @@ def load_earth_free_air_anomaly(
1920
] = "01d",
2021
region: Sequence[float] | str | None = None,
2122
registration: Literal["gridline", "pixel", None] = None,
22-
):
23+
) -> xr.DataArray:
2324
r"""
2425
Load the IGPP Earth free-air anomaly dataset in various resolutions.
2526
@@ -67,7 +68,7 @@ def load_earth_free_air_anomaly(
6768
6869
Returns
6970
-------
70-
grid : :class:`xarray.DataArray`
71+
grid
7172
The Earth free-air anomaly grid. Coordinates are latitude and
7273
longitude in degrees. Units are in mGal.
7374

pygmt/datasets/earth_geoid.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_earth_geoid"]
@@ -19,7 +20,7 @@ def load_earth_geoid(
1920
] = "01d",
2021
region: Sequence[float] | str | None = None,
2122
registration: Literal["gridline", "pixel"] = "gridline",
22-
):
23+
) -> xr.DataArray:
2324
r"""
2425
Load the EGM2008 Earth geoid dataset in various resolutions.
2526
@@ -58,7 +59,7 @@ def load_earth_geoid(
5859
5960
Returns
6061
-------
61-
grid : :class:`xarray.DataArray`
62+
grid
6263
The Earth geoid grid. Coordinates are latitude and
6364
longitude in degrees. Units are in meters.
6465

pygmt/datasets/earth_magnetic_anomaly.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213
from pygmt.exceptions import GMTInvalidInput
1314

@@ -21,7 +22,7 @@ def load_earth_magnetic_anomaly(
2122
region: Sequence[float] | str | None = None,
2223
registration: Literal["gridline", "pixel", None] = None,
2324
data_source: Literal["emag2", "emag2_4km", "wdmam"] = "emag2",
24-
):
25+
) -> xr.DataArray:
2526
r"""
2627
Load the Earth magnetic anomaly datasets in various resolutions.
2728
@@ -93,7 +94,7 @@ def load_earth_magnetic_anomaly(
9394
9495
Returns
9596
-------
96-
grid : :class:`xarray.DataArray`
97+
grid
9798
The Earth magnetic anomaly grid. Coordinates are latitude and
9899
longitude in degrees. Units are in nano Tesla (nT).
99100

pygmt/datasets/earth_mask.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_earth_mask"]
@@ -31,7 +32,7 @@ def load_earth_mask(
3132
] = "01d",
3233
region: Sequence[float] | str | None = None,
3334
registration: Literal["gridline", "pixel"] = "gridline",
34-
):
35+
) -> xr.DataArray:
3536
r"""
3637
Load the GSHHG Earth mask dataset in various resolutions.
3738
@@ -69,7 +70,7 @@ def load_earth_mask(
6970
7071
Returns
7172
-------
72-
grid : :class:`xarray.DataArray`
73+
grid
7374
The Earth mask grid. Coordinates are latitude and
7475
longitude in degrees. The node values in the mask grids are all in
7576
the 0-4 range and reflect different surface types:

pygmt/datasets/earth_relief.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213
from pygmt.exceptions import GMTInvalidInput
1314

@@ -36,7 +37,7 @@ def load_earth_relief(
3637
registration: Literal["gridline", "pixel", None] = None,
3738
data_source: Literal["igpp", "gebco", "gebcosi", "synbath"] = "igpp",
3839
use_srtm: bool = False,
39-
):
40+
) -> xr.DataArray:
4041
r"""
4142
Load the Earth relief datasets (topography and bathymetry) in various resolutions.
4243
@@ -106,7 +107,7 @@ def load_earth_relief(
106107
107108
Returns
108109
-------
109-
grid : :class:`xarray.DataArray`
110+
grid
110111
The Earth relief grid. Coordinates are latitude and longitude in
111112
degrees. Relief is in meters.
112113

pygmt/datasets/earth_vertical_gravity_gradient.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_earth_vertical_gravity_gradient"]
@@ -19,7 +20,7 @@ def load_earth_vertical_gravity_gradient(
1920
] = "01d",
2021
region: Sequence[float] | str | None = None,
2122
registration: Literal["gridline", "pixel", None] = None,
22-
):
23+
) -> xr.DataArray:
2324
r"""
2425
Load the IGPP Earth vertical gravity gradient dataset in various resolutions.
2526
@@ -67,7 +68,7 @@ def load_earth_vertical_gravity_gradient(
6768
6869
Returns
6970
-------
70-
grid : :class:`xarray.DataArray`
71+
grid
7172
The Earth vertical gravity gradient grid. Coordinates are latitude and
7273
longitude in degrees. Units are in Eotvos.
7374

pygmt/datasets/load_remote_dataset.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from pygmt.src import which
1313

1414
if TYPE_CHECKING:
15+
from collections.abc import Sequence
16+
1517
import xarray as xr
1618

1719

@@ -333,7 +335,7 @@ def _load_remote_dataset(
333335
name: str,
334336
prefix: str,
335337
resolution: str,
336-
region: str | list,
338+
region: Sequence[float] | str | None,
337339
registration: Literal["gridline", "pixel", None],
338340
) -> xr.DataArray:
339341
r"""

pygmt/datasets/mars_relief.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_mars_relief"]
@@ -32,7 +33,7 @@ def load_mars_relief(
3233
] = "01d",
3334
region: Sequence[float] | str | None = None,
3435
registration: Literal["gridline", "pixel", None] = None,
35-
):
36+
) -> xr.DataArray:
3637
r"""
3738
Load the Mars relief dataset in various resolutions.
3839
@@ -79,7 +80,7 @@ def load_mars_relief(
7980
8081
Returns
8182
-------
82-
grid : :class:`xarray.DataArray`
83+
grid
8384
The Mars relief grid. Coordinates are latitude and longitude in degrees. Relief
8485
is in meters.
8586

pygmt/datasets/mercury_relief.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_mercury_relief"]
@@ -30,7 +31,7 @@ def load_mercury_relief(
3031
] = "01d",
3132
region: Sequence[float] | str | None = None,
3233
registration: Literal["gridline", "pixel", None] = None,
33-
):
34+
) -> xr.DataArray:
3435
r"""
3536
Load the Mercury relief dataset in various resolutions.
3637
@@ -77,7 +78,7 @@ def load_mercury_relief(
7778
7879
Returns
7980
-------
80-
grid : :class:`xarray.DataArray`
81+
grid
8182
The Mercury relief grid. Coordinates are latitude and longitude in degrees.
8283
Relief is in meters.
8384

pygmt/datasets/moon_relief.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_moon_relief"]
@@ -32,7 +33,7 @@ def load_moon_relief(
3233
] = "01d",
3334
region: Sequence[float] | str | None = None,
3435
registration: Literal["gridline", "pixel", None] = None,
35-
):
36+
) -> xr.DataArray:
3637
r"""
3738
Load the Moon relief dataset in various resolutions.
3839
@@ -79,7 +80,7 @@ def load_moon_relief(
7980
8081
Returns
8182
-------
82-
grid : :class:`xarray.DataArray`
83+
grid
8384
The Moon relief grid. Coordinates are latitude and longitude in degrees. Relief
8485
is in meters.
8586

pygmt/datasets/pluto_relief.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_pluto_relief"]
@@ -30,7 +31,7 @@ def load_pluto_relief(
3031
] = "01d",
3132
region: Sequence[float] | str | None = None,
3233
registration: Literal["gridline", "pixel", None] = None,
33-
):
34+
) -> xr.DataArray:
3435
r"""
3536
Load the Pluto relief dataset in various resolutions.
3637
@@ -77,7 +78,7 @@ def load_pluto_relief(
7778
7879
Returns
7980
-------
80-
grid : :class:`xarray.DataArray`
81+
grid
8182
The Pluto relief grid. Coordinates are latitude and longitude in degrees. Relief
8283
is in meters.
8384

pygmt/datasets/samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class GMTSampleData(NamedTuple):
273273
}
274274

275275

276-
def list_sample_data() -> dict:
276+
def list_sample_data() -> dict[str, str]:
277277
"""
278278
Report datasets available for tests and documentation examples.
279279

pygmt/datasets/tile_map.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import contextlib
7+
from collections.abc import Sequence
78
from typing import Literal
89

910
from packaging.version import Version
@@ -28,7 +29,7 @@
2829

2930

3031
def load_tile_map(
31-
region: list,
32+
region: Sequence[float],
3233
zoom: int | Literal["auto"] = "auto",
3334
source: TileProvider | str | None = None,
3435
lonlat: bool = True,

pygmt/datasets/venus_relief.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Sequence
99
from typing import Literal
1010

11+
import xarray as xr
1112
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
1213

1314
__doctest_skip__ = ["load_venus_relief"]
@@ -19,7 +20,7 @@ def load_venus_relief(
1920
] = "01d",
2021
region: Sequence[float] | str | None = None,
2122
registration: Literal["gridline", "pixel"] = "gridline",
22-
):
23+
) -> xr.DataArray:
2324
r"""
2425
Load the Venus relief dataset in various resolutions.
2526
@@ -64,7 +65,7 @@ def load_venus_relief(
6465
6566
Returns
6667
-------
67-
grid : :class:`xarray.DataArray`
68+
grid
6869
The Venus relief grid. Coordinates are latitude and longitude in degrees. Relief
6970
is in meters.
7071

0 commit comments

Comments
 (0)