28
28
# type hints
29
29
P = ParamSpec ("P" )
30
30
TDataArray = TypeVar ("TDataArray" , bound = xr .DataArray )
31
- TDataArray_ = TypeVar ("TDataArray_" , bound = xr .DataArray , contravariant = True )
32
31
33
32
34
33
class DataClass (Protocol [P ]):
35
34
"""Type hint for a dataclass object."""
36
35
37
- __init__ : Callable [P , None ]
36
+ def __init__ (self , * args : P .args , ** kwargs : P .kwargs ) -> None :
37
+ ...
38
+
38
39
__dataclass_fields__ : Dict [str , Field [Any ]]
39
40
40
41
41
- class DataArrayClass (Protocol [P , TDataArray_ ]):
42
+ class DataArrayClass (Protocol [P , TDataArray ]):
42
43
"""Type hint for a dataclass object with a DataArray factory."""
43
44
44
- __init__ : Callable [P , None ]
45
+ def __init__ (self , * args : P .args , ** kwargs : P .kwargs ) -> None :
46
+ ...
47
+
45
48
__dataclass_fields__ : Dict [str , Field [Any ]]
46
- __dataoptions__ : DataOptions [TDataArray_ ]
49
+ __dataoptions__ : DataOptions [TDataArray ]
47
50
48
51
49
52
# custom classproperty
@@ -55,7 +58,7 @@ class classproperty:
55
58
56
59
"""
57
60
58
- def __init__ (self , func : Callable [..., Callable [ P , TDataArray ] ]) -> None :
61
+ def __init__ (self , func : Callable [..., Any ]) -> None :
59
62
self .__func__ = func
60
63
61
64
def __get__ (
@@ -143,9 +146,9 @@ class AsDataArray:
143
146
def new (cls : Type [DataArrayClass [P , TDataArray ]]) -> Callable [P , TDataArray ]:
144
147
"""Create a DataArray object from dataclass parameters."""
145
148
146
- init = copy (cls .__init__ )
149
+ init = copy (cls .__init__ ) # type: ignore
150
+ init .__doc__ = cls .__init__ .__doc__ # type: ignore
147
151
init .__annotations__ ["return" ] = TDataArray
148
- init .__doc__ = cls .__init__ .__doc__
149
152
150
153
@wraps (init )
151
154
def new (
0 commit comments