|
5 | 5 | * building tutorials in the documentation.
|
6 | 6 |
|
7 | 7 | """
|
| 8 | +from __future__ import annotations |
| 9 | + |
8 | 10 | import os
|
9 | 11 | import pathlib
|
| 12 | +from typing import TYPE_CHECKING |
10 | 13 |
|
11 | 14 | import numpy as np
|
12 | 15 |
|
|
15 | 18 | from .core.dataarray import DataArray
|
16 | 19 | from .core.dataset import Dataset
|
17 | 20 |
|
| 21 | +if TYPE_CHECKING: |
| 22 | + from .backends.api import T_Engine |
| 23 | + |
| 24 | + |
18 | 25 | _default_cache_dir_name = "xarray_tutorial_data"
|
19 | 26 | base_url = "https://github.com/pydata/xarray-data"
|
20 | 27 | version = "master"
|
@@ -77,13 +84,13 @@ def _check_netcdf_engine_installed(name):
|
77 | 84 |
|
78 | 85 | # idea borrowed from Seaborn
|
79 | 86 | def open_dataset(
|
80 |
| - name, |
81 |
| - cache=True, |
82 |
| - cache_dir=None, |
| 87 | + name: str, |
| 88 | + cache: bool = True, |
| 89 | + cache_dir: None | str | os.PathLike = None, |
83 | 90 | *,
|
84 |
| - engine=None, |
| 91 | + engine: T_Engine = None, |
85 | 92 | **kws,
|
86 |
| -): |
| 93 | +) -> Dataset: |
87 | 94 | """
|
88 | 95 | Open a dataset from the online repository (requires internet).
|
89 | 96 |
|
@@ -223,7 +230,7 @@ def open_rasterio(
|
223 | 230 | return arr
|
224 | 231 |
|
225 | 232 |
|
226 |
| -def load_dataset(*args, **kwargs): |
| 233 | +def load_dataset(*args, **kwargs) -> Dataset: |
227 | 234 | """
|
228 | 235 | Open, load into memory, and close a dataset from the online repository
|
229 | 236 | (requires internet).
|
@@ -264,7 +271,7 @@ def load_dataset(*args, **kwargs):
|
264 | 271 | return ds.load()
|
265 | 272 |
|
266 | 273 |
|
267 |
| -def scatter_example_dataset(*, seed=None) -> Dataset: |
| 274 | +def scatter_example_dataset(*, seed: None | int = None) -> Dataset: |
268 | 275 | """
|
269 | 276 | Create an example dataset.
|
270 | 277 |
|
|
0 commit comments