Skip to content

Commit

Permalink
Remove from __future__ import annotations
Browse files Browse the repository at this point in the history
Python does not appear to be heading in this direction and is
considering other approaches to annotations. This future import is
dropped so that we stop relying on a feature that may not come to pass.

See also #109, https://peps.python.org/pep-0649/
  • Loading branch information
mx-moth committed Jan 11, 2024
1 parent faa5933 commit 5e37d2d
Show file tree
Hide file tree
Showing 21 changed files with 11 additions and 47 deletions.
2 changes: 0 additions & 2 deletions src/emsarray/accessors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import logging

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

import abc
import dataclasses
import enum
Expand Down
2 changes: 0 additions & 2 deletions src/emsarray/conventions/_registry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import logging
import sys
import warnings
Expand Down
4 changes: 1 addition & 3 deletions src/emsarray/conventions/arakawa_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
`Arakawa grids <https://en.wikipedia.org/wiki/Arakawa_grids>`_ on Wikipedia
"""
from __future__ import annotations

import enum
import logging
from collections.abc import Hashable, Sequence
Expand Down Expand Up @@ -119,7 +117,7 @@ class ArakawaCGridKind(str, enum.Enum):
#: :meta hide-value:
node = 'node'

def __call__(self, j: int, i: int) -> ArakawaCIndex:
def __call__(self, j: int, i: int) -> 'ArakawaCIndex':
return (self, j, i)


Expand Down
2 changes: 0 additions & 2 deletions src/emsarray/conventions/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Datasets following the CF conventions with gridded datasets.
Both 1D coordinates and 2D coordinates are supported.
"""
from __future__ import annotations

import abc
import enum
import itertools
Expand Down
2 changes: 0 additions & 2 deletions src/emsarray/conventions/shoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
--------
`SHOC documentation <https://research.csiro.au/cem/software/ems/hydro/strucutured-shoc/>`_
"""
from __future__ import annotations

import logging
from collections.abc import Hashable
from functools import cached_property
Expand Down
14 changes: 9 additions & 5 deletions src/emsarray/conventions/ugrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
--------
`UGRID conventions <https://ugrid-conventions.github.io/ugrid-conventions/>`_
"""
from __future__ import annotations

import enum
import logging
import pathlib
Expand Down Expand Up @@ -39,7 +37,10 @@ def _split_coord(attr: str) -> tuple[str, str]:
return (x, y)


def buffer_faces(face_indices: numpy.ndarray, topology: Mesh2DTopology) -> numpy.ndarray:
def buffer_faces(
face_indices: numpy.ndarray,
topology: 'Mesh2DTopology',
) -> numpy.ndarray:
"""
When clipping a dataset to a region, including a buffer of extra faces
around the included faces is desired. Given an array of face indices,
Expand Down Expand Up @@ -68,7 +69,10 @@ def buffer_faces(face_indices: numpy.ndarray, topology: Mesh2DTopology) -> numpy
return cast(numpy.ndarray, numpy.fromiter(included_faces, dtype=topology.sensible_dtype))


def mask_from_face_indices(face_indices: numpy.ndarray, topology: Mesh2DTopology) -> xarray.Dataset:
def mask_from_face_indices(
face_indices: numpy.ndarray,
topology: 'Mesh2DTopology',
) -> xarray.Dataset:
"""
Make a mask dataset from a list of face indices.
This mask can later be applied using :meth:`~.Convention.apply_clip_mask`.
Expand Down Expand Up @@ -868,7 +872,7 @@ def _face_and_node_pair_iter(self) -> Iterable[tuple[int, list[tuple[int, int]]]
yield face_index, list(utils.pairwise(node_indices))

@cached_property
def dimension_for_grid_kind(self) -> dict[UGridKind, Hashable]:
def dimension_for_grid_kind(self) -> dict['UGridKind', Hashable]:
"""
Get the dimension names for each of the grid types in this dataset.
"""
Expand Down
2 changes: 0 additions & 2 deletions src/emsarray/masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
Masks are used when clipping datasets to a smaller geographic subset,
such as :meth:`.Convention.clip`.
"""
from __future__ import annotations

import functools
import itertools
import logging
Expand Down
2 changes: 0 additions & 2 deletions src/emsarray/plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

from collections.abc import Iterable
from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Union

Expand Down
2 changes: 0 additions & 2 deletions src/emsarray/state.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Dataclass for containing state required for emsarray
"""
from __future__ import annotations

import dataclasses
from typing import TYPE_CHECKING, Final, Optional, cast

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

import dataclasses
from collections.abc import Hashable, Iterable
from functools import cached_property
Expand Down
4 changes: 1 addition & 3 deletions src/emsarray/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
--------
:mod:`emsarray.operations`
"""
from __future__ import annotations

import datetime
import functools
import itertools
Expand Down Expand Up @@ -51,7 +49,7 @@ class PerfTimer:
def __init__(self) -> None:
self.running = False

def __enter__(self) -> PerfTimer:
def __enter__(self) -> 'PerfTimer':
if self.running:
raise RuntimeError("Timer is already running")
self.running = True
Expand Down
2 changes: 0 additions & 2 deletions tests/cli/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import argparse
import json
from pathlib import Path
Expand Down
2 changes: 0 additions & 2 deletions tests/conventions/test_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import dataclasses
import enum
import pathlib
Expand Down
2 changes: 0 additions & 2 deletions tests/conventions/test_cfgrid1d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import json
import pathlib

Expand Down
2 changes: 0 additions & 2 deletions tests/conventions/test_cfgrid2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
Instead of writing two identical test suites,
the SHOC simple convention is used to test both.
"""
from __future__ import annotations

import itertools
import json
import pathlib
Expand Down
2 changes: 0 additions & 2 deletions tests/conventions/test_shoc_standard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import itertools
import json
import pathlib
Expand Down
2 changes: 0 additions & 2 deletions tests/conventions/test_ugrid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import json
import pathlib
import warnings
Expand Down
2 changes: 0 additions & 2 deletions tests/masking/test_mask_dataset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import pathlib

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

import pathlib

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

import abc
import contextlib
import itertools
Expand Down

0 comments on commit 5e37d2d

Please sign in to comment.