Repository: astropenguin/xarray-dataclasses

Issue:
Fix import of Literal and Protocol
Import `Literal` (and `Protocol`) not from `typing_extensions` but from `typing`.
Use of `typing_extensions.Literal` fails `get_dims(tp)` in Python 3.8 and 3.9.

Discussion:

Patch:
diff --git a/xarray_dataclasses/datamodel.py b/xarray_dataclasses/datamodel.py
index 06fb0e0..5d8b7d1 100644
--- a/xarray_dataclasses/datamodel.py
+++ b/xarray_dataclasses/datamodel.py
@@ -4,13 +4,24 @@ __all__ = ["DataModel"]
 
 # standard library
 from dataclasses import dataclass, field, is_dataclass
-from typing import Any, Dict, Hashable, List, Optional, Tuple, Type, Union, cast
+from typing import (
+    Any,
+    Dict,
+    Hashable,
+    List,
+    Literal,
+    Optional,
+    Tuple,
+    Type,
+    Union,
+    cast,
+)
 
 
 # dependencies
 import numpy as np
 import xarray as xr
-from typing_extensions import Literal, ParamSpec, get_type_hints
+from typing_extensions import ParamSpec, get_type_hints
 
 
 # submodules
diff --git a/xarray_dataclasses/typing.py b/xarray_dataclasses/typing.py
index 4d21d28..5f16154 100644
--- a/xarray_dataclasses/typing.py
+++ b/xarray_dataclasses/typing.py
@@ -29,7 +29,9 @@ from typing import (
     Generic,
     Hashable,
     Iterable,
+    Literal,
     Optional,
+    Protocol,
     Sequence,
     Tuple,
     Type,
@@ -43,9 +45,7 @@ import numpy as np
 import xarray as xr
 from typing_extensions import (
     Annotated,
-    Literal,
     ParamSpec,
-    Protocol,
     TypeAlias,
     get_args,
     get_origin,


Test patch:
diff --git a/tests/test_data.py b/tests/test_data.py
index 35ddf07..1d9c5c9 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -1,11 +1,11 @@
 # standard library
 from dataclasses import dataclass
-from typing import Collection, Tuple, Union
+from typing import Collection, Literal as L, Tuple, Union
 
 
 # dependencies
 import numpy as np
-from typing_extensions import Annotated as Ann, Literal as L
+from typing_extensions import Annotated as Ann
 from xarray_dataclasses.typing import Attr, Coord, Coordof, Data
 
 
diff --git a/tests/test_dataarray.py b/tests/test_dataarray.py
index 23d3860..fa23ee7 100644
--- a/tests/test_dataarray.py
+++ b/tests/test_dataarray.py
@@ -1,12 +1,11 @@
 # standard library
 from dataclasses import dataclass
-from typing import Tuple
+from typing import Literal, Tuple
 
 
 # dependencies
 import numpy as np
 import xarray as xr
-from typing_extensions import Literal
 
 
 # submodules
diff --git a/tests/test_datamodel.py b/tests/test_datamodel.py
index a79a412..a95b1b0 100644
--- a/tests/test_datamodel.py
+++ b/tests/test_datamodel.py
@@ -1,10 +1,6 @@
 # standard library
 from dataclasses import dataclass
-from typing import Tuple
-
-
-# dependencies
-from typing_extensions import Literal
+from typing import Literal, Tuple
 
 
 # submodules
diff --git a/tests/test_dataset.py b/tests/test_dataset.py
index 41e4470..7b3b66a 100644
--- a/tests/test_dataset.py
+++ b/tests/test_dataset.py
@@ -1,12 +1,11 @@
 # standard library
 from dataclasses import dataclass
-from typing import Tuple
+from typing import Literal, Tuple
 
 
 # dependencies
 import numpy as np
 import xarray as xr
-from typing_extensions import Literal
 
 
 # submodules
diff --git a/tests/test_typing.py b/tests/test_typing.py
index 06cf3d4..92de2e4 100644
--- a/tests/test_typing.py
+++ b/tests/test_typing.py
@@ -1,12 +1,11 @@
 # standard library
-from typing import Any, Tuple, Union
+from typing import Any, Literal as L, Tuple, Union
 
 
 # dependencies
 import numpy as np
 from pytest import mark
 from typing_extensions import Annotated as Ann
-from typing_extensions import Literal as L
 
 
 # submodules