File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 18
18
Union ,
19
19
)
20
20
21
+ from typing_extensions import overload
22
+
21
23
try :
22
24
# python 3.8+
23
25
from typing import Literal # type: ignore[attr-defined]
@@ -89,6 +91,19 @@ def __hash__(self) -> int:
89
91
_DataTypeClass = Type [_Dtype ]
90
92
91
93
94
+ @overload
95
+ def immutable (
96
+ pandera_dtype_cls : _DataTypeClass , # pylint: disable=W0613
97
+ ** dataclass_kwargs : Any , # pylint: disable=W0613
98
+ ) -> _DataTypeClass : ...
99
+
100
+
101
+ @overload
102
+ def immutable (
103
+ ** dataclass_kwargs : Any , # pylint: disable=W0613
104
+ ) -> Callable [[_DataTypeClass ], _DataTypeClass ]: ...
105
+
106
+
92
107
def immutable (
93
108
pandera_dtype_cls : Optional [_DataTypeClass ] = None , ** dataclass_kwargs : Any
94
109
) -> Union [_DataTypeClass , Callable [[_DataTypeClass ], _DataTypeClass ]]:
Original file line number Diff line number Diff line change @@ -1515,3 +1515,15 @@ def sqrt(cls, series):
1515
1515
assert Schema .validate (df ).equals ( # type: ignore [attr-defined]
1516
1516
pd .DataFrame ({"a" : [11.0 ], "abc" : [1.0 ], "cba" : [200.0 ]})
1517
1517
)
1518
+
1519
+
1520
+ def test_pandera_dtype () -> None :
1521
+ class Schema (pa .DataFrameModel ):
1522
+ a : Series [pa .Float ]
1523
+ b : Series [pa .Int ]
1524
+ c : Series [pa .String ]
1525
+
1526
+ df = pd .DataFrame ({"a" : [1.0 ], "b" : [1 ], "c" : ["1" ]})
1527
+ assert Schema .validate (df ).equals ( # type: ignore [attr-defined]
1528
+ pd .DataFrame ({"a" : [1.0 ], "b" : [1 ], "c" : ["1" ]})
1529
+ )
You can’t perform that action at this time.
0 commit comments