|
146 | 146 | _T1 = TypeVar("_T1") |
147 | 147 | _T2 = TypeVar("_T2") |
148 | 148 | _T3 = TypeVar("_T3") |
149 | | - _T4 = TypeVar("_T4") |
150 | | - _T5 = TypeVar("_T5") |
151 | | - _T6 = TypeVar("_T6") |
152 | | - _T7 = TypeVar("_T7") |
153 | 149 | _Fn = TypeVar("_Fn", bound="Callable[..., Any]") |
154 | 150 | P = ParamSpec("P") |
155 | 151 | R = TypeVar("R") |
@@ -748,76 +744,6 @@ def isinstance_or_issubclass( |
748 | 744 | ) -> TypeIs[_T1 | _T2 | _T3 | type[_T1 | _T2 | _T3]]: ... |
749 | 745 |
|
750 | 746 |
|
751 | | -@overload |
752 | | -def isinstance_or_issubclass( |
753 | | - obj_or_cls: type, cls_or_tuple: tuple[type[_T1], type[_T2], type[_T3], type[_T4]] |
754 | | -) -> TypeIs[type[_T1 | _T2 | _T3 | _T4]]: ... |
755 | | - |
756 | | - |
757 | | -@overload |
758 | | -def isinstance_or_issubclass( |
759 | | - obj_or_cls: object | type, |
760 | | - cls_or_tuple: tuple[type[_T1], type[_T2], type[_T3], type[_T4]], |
761 | | -) -> TypeIs[_T1 | _T2 | _T3 | _T4 | type[_T1 | _T2 | _T3 | _T4]]: ... |
762 | | - |
763 | | - |
764 | | -@overload |
765 | | -def isinstance_or_issubclass( |
766 | | - obj_or_cls: type, |
767 | | - cls_or_tuple: tuple[type[_T1], type[_T2], type[_T3], type[_T4], type[_T5]], |
768 | | -) -> TypeIs[type[_T1 | _T2 | _T3 | _T4 | _T5]]: ... |
769 | | - |
770 | | - |
771 | | -@overload |
772 | | -def isinstance_or_issubclass( |
773 | | - obj_or_cls: object | type, |
774 | | - cls_or_tuple: tuple[type[_T1], type[_T2], type[_T3], type[_T4], type[_T5]], |
775 | | -) -> TypeIs[_T1 | _T2 | _T3 | _T4 | _T5 | type[_T1 | _T2 | _T3 | _T4 | _T5]]: ... |
776 | | - |
777 | | - |
778 | | -@overload |
779 | | -def isinstance_or_issubclass( |
780 | | - obj_or_cls: type, |
781 | | - cls_or_tuple: tuple[type[_T1], type[_T2], type[_T3], type[_T4], type[_T5], type[_T6]], |
782 | | -) -> TypeIs[type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6]]: ... |
783 | | - |
784 | | - |
785 | | -@overload |
786 | | -def isinstance_or_issubclass( |
787 | | - obj_or_cls: object | type, |
788 | | - cls_or_tuple: tuple[type[_T1], type[_T2], type[_T3], type[_T4], type[_T5], type[_T6]], |
789 | | -) -> TypeIs[ |
790 | | - _T1 | _T2 | _T3 | _T4 | _T5 | _T6 | type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6] |
791 | | -]: ... |
792 | | - |
793 | | - |
794 | | -@overload |
795 | | -def isinstance_or_issubclass( |
796 | | - obj_or_cls: type, |
797 | | - cls_or_tuple: tuple[ |
798 | | - type[_T1], type[_T2], type[_T3], type[_T4], type[_T5], type[_T6], type[_T7] |
799 | | - ], |
800 | | -) -> TypeIs[type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6 | _T7]]: ... |
801 | | - |
802 | | - |
803 | | -@overload |
804 | | -def isinstance_or_issubclass( |
805 | | - obj_or_cls: object | type, |
806 | | - cls_or_tuple: tuple[ |
807 | | - type[_T1], type[_T2], type[_T3], type[_T4], type[_T5], type[_T6], type[_T7] |
808 | | - ], |
809 | | -) -> TypeIs[ |
810 | | - _T1 |
811 | | - | _T2 |
812 | | - | _T3 |
813 | | - | _T4 |
814 | | - | _T5 |
815 | | - | _T6 |
816 | | - | _T7 |
817 | | - | type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6 | _T7] |
818 | | -]: ... |
819 | | - |
820 | | - |
821 | 747 | @overload |
822 | 748 | def isinstance_or_issubclass( |
823 | 749 | obj_or_cls: Any, cls_or_tuple: tuple[type, ...] |
@@ -1207,21 +1133,12 @@ def maybe_convert_dtypes( |
1207 | 1133 | b boolean |
1208 | 1134 | dtype: object |
1209 | 1135 | """ |
1210 | | - obj_any = cast("Any", obj) |
1211 | | - native_obj = obj_any.to_native() |
1212 | | - if is_pandas_like_dataframe(native_obj): |
1213 | | - return obj_any._with_compliant( |
1214 | | - obj_any._compliant_frame._with_native( |
1215 | | - native_obj.convert_dtypes(*args, **kwargs) |
1216 | | - ) |
1217 | | - ) |
1218 | | - if is_pandas_like_series(native_obj): |
1219 | | - return obj_any._with_compliant( |
1220 | | - obj_any._compliant_series._with_native( |
1221 | | - native_obj.convert_dtypes(*args, **kwargs) |
1222 | | - ) |
1223 | | - ) |
1224 | | - return obj_any |
| 1136 | + if not obj.implementation.is_pandas_like(): |
| 1137 | + return obj |
| 1138 | + result = obj._with_compliant( |
| 1139 | + obj._compliant._with_native(obj.to_native().convert_dtypes(*args, **kwargs)) |
| 1140 | + ) |
| 1141 | + return cast("FrameOrSeriesT", result) |
1225 | 1142 |
|
1226 | 1143 |
|
1227 | 1144 | def scale_bytes(sz: int, unit: SizeUnit) -> int | float: |
|
0 commit comments