Skip to content

Commit bdd1da8

Browse files
Type xr.tutorial (#6897)
* Type tutorial * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8417f49 commit bdd1da8

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

xarray/tutorial.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
* building tutorials in the documentation.
66
77
"""
8+
from __future__ import annotations
9+
810
import os
911
import pathlib
12+
from typing import TYPE_CHECKING
1013

1114
import numpy as np
1215

@@ -15,6 +18,10 @@
1518
from .core.dataarray import DataArray
1619
from .core.dataset import Dataset
1720

21+
if TYPE_CHECKING:
22+
from .backends.api import T_Engine
23+
24+
1825
_default_cache_dir_name = "xarray_tutorial_data"
1926
base_url = "https://github.com/pydata/xarray-data"
2027
version = "master"
@@ -77,13 +84,13 @@ def _check_netcdf_engine_installed(name):
7784

7885
# idea borrowed from Seaborn
7986
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,
8390
*,
84-
engine=None,
91+
engine: T_Engine = None,
8592
**kws,
86-
):
93+
) -> Dataset:
8794
"""
8895
Open a dataset from the online repository (requires internet).
8996
@@ -223,7 +230,7 @@ def open_rasterio(
223230
return arr
224231

225232

226-
def load_dataset(*args, **kwargs):
233+
def load_dataset(*args, **kwargs) -> Dataset:
227234
"""
228235
Open, load into memory, and close a dataset from the online repository
229236
(requires internet).
@@ -264,7 +271,7 @@ def load_dataset(*args, **kwargs):
264271
return ds.load()
265272

266273

267-
def scatter_example_dataset(*, seed=None) -> Dataset:
274+
def scatter_example_dataset(*, seed: None | int = None) -> Dataset:
268275
"""
269276
Create an example dataset.
270277

0 commit comments

Comments
 (0)