Skip to content

Typing of Dataset #6661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _dataset_from_backend_dataset(


def open_dataset(
filename_or_obj: str | os.PathLike,
filename_or_obj: str | os.PathLike | AbstractDataStore,
*,
engine: T_Engine = None,
chunks: T_Chunks = None,
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/cfgrib_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import warnings

Expand Down
6 changes: 4 additions & 2 deletions xarray/backends/file_manager.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

import contextlib
import io
import threading
import warnings
from typing import Any, Dict
from typing import Any

from ..core import utils
from ..core.options import OPTIONS
Expand All @@ -16,7 +18,7 @@
assert FILE_CACHE.maxsize, "file cache must be at least size one"


REF_COUNTS: Dict[Any, int] = {}
REF_COUNTS: dict[Any, int] = {}

_DEFAULT_MODE = utils.ReprObject("<unused>")

Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import functools
import io
import os
Expand Down
6 changes: 4 additions & 2 deletions xarray/backends/locks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

import multiprocessing
import threading
import weakref
from typing import Any, MutableMapping, Optional
from typing import Any, MutableMapping

try:
from dask.utils import SerializableLock
Expand Down Expand Up @@ -62,7 +64,7 @@ def _get_lock_maker(scheduler=None):
return _LOCK_MAKERS[scheduler]


def _get_scheduler(get=None, collection=None) -> Optional[str]:
def _get_scheduler(get=None, collection=None) -> str | None:
"""Determine the dask scheduler that is being used.

None is returned if no dask scheduler is active.
Expand Down
8 changes: 5 additions & 3 deletions xarray/backends/lru_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import threading
from collections import OrderedDict
from typing import Any, Callable, Iterator, MutableMapping, Optional, TypeVar
from typing import Any, Callable, Iterator, MutableMapping, TypeVar

K = TypeVar("K")
V = TypeVar("V")
Expand All @@ -21,10 +23,10 @@ class LRUCache(MutableMapping[K, V]):
the cache, e.g., ``cache.maxsize = new_size``.
"""

_cache: "OrderedDict[K, V]"
_cache: OrderedDict[K, V]
_maxsize: int
_lock: threading.RLock
_on_evict: Optional[Callable[[K, V], Any]]
_on_evict: Callable[[K, V], Any] | None

__slots__ = ("_cache", "_lock", "_maxsize", "_on_evict")

Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/memory.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import copy

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/netCDF4_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import functools
import operator
import os
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/netcdf3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import unicodedata

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/plugins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import functools
import inspect
import itertools
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/pseudonetcdf_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np

from ..core import indexing
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/pydap_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np

from ..core import indexing
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/pynio_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np

from ..core import indexing
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/rasterio_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import warnings

Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/scipy_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import gzip
import io
import os
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/store.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .. import conventions
from ..core.dataset import Dataset
from .common import BACKEND_ENTRYPOINTS, AbstractDataStore, BackendEntrypoint
Expand Down
2 changes: 2 additions & 0 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import os
import warnings
Expand Down
2 changes: 2 additions & 0 deletions xarray/coding/calendar_ops.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
import pandas as pd

Expand Down
1 change: 1 addition & 0 deletions xarray/coding/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import annotations

import numpy as np
import pandas as pd
Expand Down
2 changes: 2 additions & 0 deletions xarray/coding/strings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Coders for strings."""
from __future__ import annotations

from functools import partial

import numpy as np
Expand Down
4 changes: 3 additions & 1 deletion xarray/coding/times.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
import warnings
from datetime import datetime, timedelta
Expand Down Expand Up @@ -348,7 +350,7 @@ def _infer_time_units_from_diff(unique_timedeltas):
return "seconds"


def infer_calendar_name(dates) -> "CFCalendar":
def infer_calendar_name(dates) -> CFCalendar:
"""Given an array of datetimes, infer the CF calendar name"""
if is_np_datetime_like(dates.dtype):
return "proleptic_gregorian"
Expand Down
2 changes: 2 additions & 0 deletions xarray/coding/variables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Coders for individual Variable objects."""
from __future__ import annotations

import warnings
from functools import partial
from typing import Any, Hashable
Expand Down
Loading