From 62073f4897f6bd61ab4999313068f22a0764133b Mon Sep 17 00:00:00 2001 From: yassun7010 Date: Mon, 30 Sep 2024 20:08:35 +0900 Subject: [PATCH] feat: add overload. Signed-off-by: yassun7010 --- pandera/dtypes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandera/dtypes.py b/pandera/dtypes.py index 2e2043fa6..64f5f71db 100644 --- a/pandera/dtypes.py +++ b/pandera/dtypes.py @@ -18,6 +18,8 @@ Union, ) +from typing_extensions import overload + try: # python 3.8+ from typing import Literal # type: ignore[attr-defined] @@ -89,6 +91,18 @@ def __hash__(self) -> int: _DataTypeClass = Type[_Dtype] +@overload +def immutable( + pandera_dtype_cls: _DataTypeClass, **dataclass_kwargs: Any +) -> _DataTypeClass: + ... + +@overload +def immutable( + pandera_dtype_cls: None = None, **dataclass_kwargs: Any +) -> Callable[[_DataTypeClass], _DataTypeClass]: + ... + def immutable( pandera_dtype_cls: Optional[_DataTypeClass] = None, **dataclass_kwargs: Any ) -> Union[_DataTypeClass, Callable[[_DataTypeClass], _DataTypeClass]]: