@@ -2914,3 +2914,113 @@ def test_timedeltaseries_operators() -> None:
2914
2914
pd .Series ,
2915
2915
pd .Timedelta ,
2916
2916
)
2917
+
2918
+
2919
+ def test_pipe () -> None :
2920
+ ser = pd .Series (range (10 ))
2921
+
2922
+ def first_arg_series (
2923
+ ser : pd .Series ,
2924
+ positional_only : int ,
2925
+ / ,
2926
+ argument_1 : list [float ],
2927
+ argument_2 : str ,
2928
+ * ,
2929
+ keyword_only : tuple [int , int ],
2930
+ ) -> pd .Series :
2931
+ return ser
2932
+
2933
+ check (
2934
+ assert_type (
2935
+ ser .pipe (
2936
+ first_arg_series ,
2937
+ 1 ,
2938
+ [1.0 , 2.0 ],
2939
+ argument_2 = "hi" ,
2940
+ keyword_only = (1 , 2 ),
2941
+ ),
2942
+ pd .Series ,
2943
+ ),
2944
+ pd .Series ,
2945
+ )
2946
+
2947
+ if TYPE_CHECKING_INVALID_USAGE :
2948
+ ser .pipe (
2949
+ first_arg_series ,
2950
+ "a" , # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
2951
+ [1.0 , 2.0 ],
2952
+ argument_2 = "hi" ,
2953
+ keyword_only = (1 , 2 ),
2954
+ )
2955
+ ser .pipe (
2956
+ first_arg_series ,
2957
+ 1 ,
2958
+ [1.0 , "b" ], # type: ignore[list-item] # pyright: ignore[reportGeneralTypeIssues]
2959
+ argument_2 = "hi" ,
2960
+ keyword_only = (1 , 2 ),
2961
+ )
2962
+ ser .pipe (
2963
+ first_arg_series ,
2964
+ 1 ,
2965
+ [1.0 , 2.0 ],
2966
+ argument_2 = 11 , # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
2967
+ keyword_only = (1 , 2 ),
2968
+ )
2969
+ ser .pipe (
2970
+ first_arg_series ,
2971
+ 1 ,
2972
+ [1.0 , 2.0 ],
2973
+ argument_2 = "hi" ,
2974
+ keyword_only = (1 ,), # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
2975
+ )
2976
+ ser .pipe ( # type: ignore[call-arg]
2977
+ first_arg_series ,
2978
+ 1 ,
2979
+ [1.0 , 2.0 ],
2980
+ argument_3 = "hi" , # pyright: ignore[reportGeneralTypeIssues]
2981
+ keyword_only = (1 , 2 ),
2982
+ )
2983
+ ser .pipe ( # type: ignore[misc]
2984
+ first_arg_series ,
2985
+ 1 ,
2986
+ [1.0 , 2.0 ],
2987
+ 11 , # type: ignore[arg-type]
2988
+ (1 , 2 ), # pyright: ignore[reportGeneralTypeIssues]
2989
+ )
2990
+ ser .pipe ( # type: ignore[call-arg]
2991
+ first_arg_series ,
2992
+ positional_only = 1 , # pyright: ignore[reportGeneralTypeIssues]
2993
+ argument_1 = [1.0 , 2.0 ],
2994
+ argument_2 = 11 , # type: ignore[arg-type]
2995
+ keyword_only = (1 , 2 ),
2996
+ )
2997
+
2998
+ def first_arg_not_series (argument_1 : int , ser : pd .Series ) -> pd .Series :
2999
+ return ser
3000
+
3001
+ check (
3002
+ assert_type (
3003
+ ser .pipe (
3004
+ (first_arg_not_series , "ser" ),
3005
+ 1 ,
3006
+ ),
3007
+ pd .Series ,
3008
+ ),
3009
+ pd .Series ,
3010
+ )
3011
+
3012
+ if TYPE_CHECKING_INVALID_USAGE :
3013
+ ser .pipe (
3014
+ (
3015
+ first_arg_not_series , # type: ignore[arg-type]
3016
+ 1 , # pyright: ignore[reportGeneralTypeIssues]
3017
+ ),
3018
+ 1 ,
3019
+ )
3020
+ ser .pipe (
3021
+ (
3022
+ 1 , # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
3023
+ "df" ,
3024
+ ),
3025
+ 1 ,
3026
+ )
0 commit comments