Skip to content

Commit f1aeccb

Browse files
authored
#203 Merge pull request from astropenguin/astropenguin/issue202
Fix import of Literal and Protocol
2 parents 102c962 + 1c063f1 commit f1aeccb

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

tests/test_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# standard library
22
from dataclasses import dataclass
3-
from typing import Collection, Tuple, Union
3+
from typing import Collection, Literal as L, Tuple, Union
44

55

66
# dependencies
77
import numpy as np
8-
from typing_extensions import Annotated as Ann, Literal as L
8+
from typing_extensions import Annotated as Ann
99
from xarray_dataclasses.typing import Attr, Coord, Coordof, Data
1010

1111

tests/test_dataarray.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# standard library
22
from dataclasses import dataclass
3-
from typing import Tuple
3+
from typing import Literal, Tuple
44

55

66
# dependencies
77
import numpy as np
88
import xarray as xr
9-
from typing_extensions import Literal
109

1110

1211
# submodules

tests/test_datamodel.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# standard library
22
from dataclasses import dataclass
3-
from typing import Tuple
4-
5-
6-
# dependencies
7-
from typing_extensions import Literal
3+
from typing import Literal, Tuple
84

95

106
# submodules

tests/test_dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# standard library
22
from dataclasses import dataclass
3-
from typing import Tuple
3+
from typing import Literal, Tuple
44

55

66
# dependencies
77
import numpy as np
88
import xarray as xr
9-
from typing_extensions import Literal
109

1110

1211
# submodules

tests/test_typing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# standard library
2-
from typing import Any, Tuple, Union
2+
from typing import Any, Literal as L, Tuple, Union
33

44

55
# dependencies
66
import numpy as np
77
from pytest import mark
88
from typing_extensions import Annotated as Ann
9-
from typing_extensions import Literal as L
109

1110

1211
# submodules

xarray_dataclasses/datamodel.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44

55
# standard library
66
from dataclasses import dataclass, field, is_dataclass
7-
from typing import Any, Dict, Hashable, List, Optional, Tuple, Type, Union, cast
7+
from typing import (
8+
Any,
9+
Dict,
10+
Hashable,
11+
List,
12+
Literal,
13+
Optional,
14+
Tuple,
15+
Type,
16+
Union,
17+
cast,
18+
)
819

920

1021
# dependencies
1122
import numpy as np
1223
import xarray as xr
13-
from typing_extensions import Literal, ParamSpec, get_type_hints
24+
from typing_extensions import ParamSpec, get_type_hints
1425

1526

1627
# submodules

xarray_dataclasses/typing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
Generic,
3030
Hashable,
3131
Iterable,
32+
Literal,
3233
Optional,
34+
Protocol,
3335
Sequence,
3436
Tuple,
3537
Type,
@@ -43,9 +45,7 @@
4345
import xarray as xr
4446
from typing_extensions import (
4547
Annotated,
46-
Literal,
4748
ParamSpec,
48-
Protocol,
4949
TypeAlias,
5050
get_args,
5151
get_origin,

0 commit comments

Comments
 (0)