Repository: astropenguin/xarray-dataclasses
Pull request #83 (2021-09-16 16:52:27)

Release v0.5.0


Patch:
diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml
index a02b936..6324123 100644
--- a/.github/workflows/pypi.yml
+++ b/.github/workflows/pypi.yml
@@ -14,7 +14,7 @@ jobs:
       - name: Setup Python
         uses: actions/setup-python@v2
         with:
-          python-version: 3.8
+          python-version: 3.9
       - name: Install dependencies
         run: |
           pip install poetry
diff --git a/pyproject.toml b/pyproject.toml
index a9c8b01..2c929b9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "xarray-dataclasses"
-version = "0.4.0"
+version = "0.5.0"
 description = "xarray extension for typed DataArray and Dataset creation"
 authors = ["Akio Taniguchi <taniguchi@a.phys.nagoya-u.ac.jp>"]
 license = "MIT"
diff --git a/xarray_dataclasses/__init__.py b/xarray_dataclasses/__init__.py
index d181e42..fdf3fee 100644
--- a/xarray_dataclasses/__init__.py
+++ b/xarray_dataclasses/__init__.py
@@ -1,7 +1,7 @@
 # flake8: noqa
 # type: ignore
 __author__ = "Akio Taniguchi"
-__version__ = "0.4.0"
+__version__ = "0.5.0"
 
 
 # for Python 3.7 - 3.8
diff --git a/xarray_dataclasses/dataarray.py b/xarray_dataclasses/dataarray.py
index a26b1a4..685d424 100644
--- a/xarray_dataclasses/dataarray.py
+++ b/xarray_dataclasses/dataarray.py
@@ -8,7 +8,7 @@ from types import MethodType
 from typing import Any, Callable, Dict, overload, Sequence, Type, TypeVar, Union
 
 
-# third-party packages
+# dependencies
 import numpy as np
 import xarray as xr
 from typing_extensions import Literal, ParamSpec, Protocol
@@ -16,6 +16,7 @@ from typing_extensions import Literal, ParamSpec, Protocol
 
 # submodules
 from .datamodel import DataModel
+from .typing import Reference
 from .utils import copy_function
 
 
@@ -23,7 +24,6 @@ from .utils import copy_function
 P = ParamSpec("P")
 R = TypeVar("R", bound=xr.DataArray)
 Order = Literal["C", "F"]
-Reference = Union[xr.DataArray, xr.Dataset, None]
 Shape = Union[Sequence[int], int]
 
 
diff --git a/xarray_dataclasses/datamodel.py b/xarray_dataclasses/datamodel.py
index 57c57b0..70e08e7 100644
--- a/xarray_dataclasses/datamodel.py
+++ b/xarray_dataclasses/datamodel.py
@@ -1,9 +1,12 @@
+__all__ = ["DataModel"]
+
+
 # standard library
 from dataclasses import dataclass, field, Field, InitVar, is_dataclass
 from typing import Any, Callable, cast, Generic, List, TypeVar, Union
 
 
-# third-party packages
+# dependencies
 import numpy as np
 import xarray as xr
 from typing_extensions import get_args, TypedDict
@@ -18,6 +21,7 @@ from .typing import (
     FieldType,
     get_dims,
     get_dtype,
+    Reference,
     unannotate,
 )
 from .utils import resolve_class
@@ -25,7 +29,6 @@ from .utils import resolve_class
 
 # type hints
 R = TypeVar("R")
-Reference = Union[xr.DataArray, xr.Dataset, None]
 Factory = Callable[[Any, Reference], R]
 
 
@@ -59,9 +62,11 @@ class FieldModel(Generic[R]):
     """Factory function to create an object."""
 
     def __post_init__(self, factory: Factory[R]) -> None:
+        """Add a factory to the field model."""
         self.factory = factory
 
     def __call__(self, reference: Reference = None) -> R:
+        """Create an object from the value and a reference."""
         return self.factory(self.value, reference)
 
 
diff --git a/xarray_dataclasses/dataset.py b/xarray_dataclasses/dataset.py
index dd62cc4..e6309b3 100644
--- a/xarray_dataclasses/dataset.py
+++ b/xarray_dataclasses/dataset.py
@@ -5,23 +5,23 @@ __all__ = ["asdataset", "AsDataset"]
 from dataclasses import Field
 from functools import wraps
 from types import MethodType
-from typing import Any, Callable, Dict, overload, Type, TypeVar, Union
+from typing import Any, Callable, Dict, overload, Type, TypeVar
 
 
-# third-party packages
+# dependencies
 import xarray as xr
 from typing_extensions import ParamSpec, Protocol
 
 
 # submodules
 from .datamodel import DataModel
+from .typing import Reference
 from .utils import copy_function
 
 
 # type hints
 P = ParamSpec("P")
 R = TypeVar("R", bound=xr.Dataset)
-Reference = Union[xr.DataArray, xr.Dataset, None]
 
 
 class DataClass(Protocol[P]):
diff --git a/xarray_dataclasses/typing.py b/xarray_dataclasses/typing.py
index 4cbb10d..9a40890 100644
--- a/xarray_dataclasses/typing.py
+++ b/xarray_dataclasses/typing.py
@@ -16,7 +16,8 @@ from typing import (
 )
 
 
-# third-party packages
+# dependencies
+import xarray as xr
 from typing_extensions import (
     Annotated,
     get_args,
@@ -61,6 +62,7 @@ TDtype = TypeVar("TDtype", covariant=True)
 Dims = Tuple[str, ...]
 Dtype = Optional[str]
 NoneType = type(None)
+Reference = Union[xr.DataArray, xr.Dataset, None]
 
 
 @runtime_checkable
@@ -77,7 +79,7 @@ class ArrayLike(Protocol[TDims, TDtype]):
         ...
 
     @property
-    def shape(self) -> Union[Tuple[int, ...], int]:
+    def shape(self) -> Tuple[int, ...]:
         """Shape of the object."""
         ...
 


Test patch:
diff --git a/tests/test_metadata.py b/tests/test_metadata.py
index c38b4af..1a0f89c 100644
--- a/tests/test_metadata.py
+++ b/tests/test_metadata.py
@@ -8,4 +8,4 @@ def test_author():
 
 
 def test_version():
-    assert xarray_dataclasses.__version__ == "0.4.0"
+    assert xarray_dataclasses.__version__ == "0.5.0"