Skip to content

Commit 9c1c9a0

Browse files
committed
fixup
1 parent 7c26e8e commit 9c1c9a0

File tree

1 file changed

+32
-41
lines changed

1 file changed

+32
-41
lines changed

tests/test_pandas.py

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
TYPE_CHECKING_INVALID_USAGE,
3333
check,
3434
np_1darray,
35+
np_1darray_anyint,
3536
np_1darray_dt,
3637
np_1darray_float,
3738
np_1darray_int64,
@@ -77,23 +78,16 @@ def test_types_to_datetime() -> None:
7778
pd.DatetimeIndex,
7879
)
7980
check(
80-
assert_type(
81-
pd.to_datetime([1, 2], unit="D", origin=3),
82-
pd.DatetimeIndex,
83-
),
81+
assert_type(pd.to_datetime([1, 2], unit="D", origin=3), pd.DatetimeIndex),
8482
pd.DatetimeIndex,
8583
)
8684
check(
87-
assert_type(
88-
pd.to_datetime(["2022-01-03", "2022-02-22"]),
89-
pd.DatetimeIndex,
90-
),
85+
assert_type(pd.to_datetime(["2022-01-03", "2022-02-22"]), pd.DatetimeIndex),
9186
pd.DatetimeIndex,
9287
)
9388
check(
9489
assert_type(
95-
pd.to_datetime(pd.Index(["2022-01-03", "2022-02-22"])),
96-
pd.DatetimeIndex,
90+
pd.to_datetime(pd.Index(["2022-01-03", "2022-02-22"])), pd.DatetimeIndex
9791
),
9892
pd.DatetimeIndex,
9993
)
@@ -136,9 +130,10 @@ def test_types_concat_none() -> None:
136130
pd.DataFrame,
137131
)
138132

139-
if TYPE_CHECKING_INVALID_USAGE:
140-
# using assert_type as otherwise the second call would not be type-checked
133+
def _0() -> None: # pyright: ignore[reportUnusedFunction]
141134
assert_type(pd.concat({"a": None}), Never)
135+
136+
def _1() -> None: # pyright: ignore[reportUnusedFunction]
142137
assert_type(pd.concat([None]), Never)
143138

144139

@@ -201,13 +196,7 @@ def test_types_concat() -> None:
201196

202197
check(assert_type(ts1, "pd.Series[int]"), pd.Series, np.integer)
203198
check(assert_type(ts2, "pd.Series[int]"), pd.Series, np.integer)
204-
check(
205-
assert_type(
206-
pd.concat({1: s, None: s2}, axis=1),
207-
pd.DataFrame,
208-
),
209-
pd.DataFrame,
210-
)
199+
check(assert_type(pd.concat({1: s, None: s2}, axis=1), pd.DataFrame), pd.DataFrame)
211200

212201
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
213202
df2 = pd.DataFrame(data={"col1": [10, 20], "col2": [30, 40]})
@@ -725,9 +714,21 @@ def test_hashing() -> None:
725714
b = pd.Series(a)
726715
c = pd.DataFrame({"a": a, "b": a})
727716
d = pd.Index(b)
728-
check(assert_type(pdutil.hash_pandas_object(b), "pd.Series[int]"), pd.Series, int)
729-
check(assert_type(pdutil.hash_pandas_object(c), "pd.Series[int]"), pd.Series, int)
730-
check(assert_type(pdutil.hash_pandas_object(d), "pd.Series[int]"), pd.Series, int)
717+
check(
718+
assert_type(pdutil.hash_pandas_object(b), "pd.Series[int]"),
719+
pd.Series,
720+
np.uint64,
721+
)
722+
check(
723+
assert_type(pdutil.hash_pandas_object(c), "pd.Series[int]"),
724+
pd.Series,
725+
np.uint64,
726+
)
727+
check(
728+
assert_type(pdutil.hash_pandas_object(d), "pd.Series[int]"),
729+
pd.Series,
730+
np.uint64,
731+
)
731732
check(
732733
assert_type(
733734
pdutil.hash_pandas_object(
@@ -736,7 +737,7 @@ def test_hashing() -> None:
736737
"pd.Series[int]",
737738
),
738739
pd.Series,
739-
int,
740+
np.uint64,
740741
)
741742

742743

@@ -763,57 +764,47 @@ def test_to_numeric_scalar() -> None:
763764

764765
def test_to_numeric_array_like() -> None:
765766
check(
766-
assert_type(pd.to_numeric([1, 2, 3]), np_1darray[np.integer]),
767-
np_1darray,
768-
np.integer,
767+
assert_type(pd.to_numeric([1, 2, 3]), np_1darray_anyint), np_1darray, np.integer
769768
)
770769
check(
771-
assert_type(pd.to_numeric([1.0, 2.0, 3.0]), np_1darray[np.floating]),
770+
assert_type(pd.to_numeric([1.0, 2.0, 3.0]), np_1darray_float),
772771
np_1darray,
773772
np.floating,
774773
)
775774
check(
776-
assert_type(pd.to_numeric([1.0, 2.0, "3.0"]), np_1darray[np.floating]),
775+
assert_type(pd.to_numeric([1.0, 2.0, "3.0"]), np_1darray_float),
777776
np_1darray,
778777
np.floating,
779778
)
780779
check(
781780
assert_type(
782781
pd.to_numeric(np.array([1.0, 2.0, "3.0"], dtype=object)),
783-
np_1darray[np.floating],
782+
np_1darray_float,
784783
),
785784
np_1darray,
786785
np.floating,
787786
)
788787
check(
789788
assert_type(
790-
pd.to_numeric([1.0, 2.0, "blerg"], errors="coerce"), np_1darray[np.floating]
789+
pd.to_numeric([1.0, 2.0, "blerg"], errors="coerce"), np_1darray_float
791790
),
792791
np_1darray,
793792
np.floating,
794793
)
795794
check(
796-
assert_type(pd.to_numeric((1.0, 2.0, 3.0)), np_1darray[np.floating]),
795+
assert_type(pd.to_numeric((1.0, 2.0, 3.0)), np_1darray_float),
797796
np_1darray,
798797
np.floating,
799798
)
800799
check(
801-
assert_type(
802-
pd.to_numeric([1, 2, 3], downcast="unsigned"), np_1darray[np.integer]
803-
),
800+
assert_type(pd.to_numeric([1, 2, 3], downcast="unsigned"), np_1darray_anyint),
804801
np_1darray,
805802
np.integer,
806803
)
807804

808805

809806
def test_to_numeric_array_series() -> None:
810-
check(
811-
assert_type(
812-
pd.to_numeric(pd.Series([1, 2, 3])),
813-
pd.Series,
814-
),
815-
pd.Series,
816-
)
807+
check(assert_type(pd.to_numeric(pd.Series([1, 2, 3])), pd.Series), pd.Series)
817808
check(
818809
assert_type(
819810
pd.to_numeric(pd.Series([1, 2, "blerg"]), errors="coerce"),

0 commit comments

Comments
 (0)