Skip to content

Commit

Permalink
mypy fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Aug 22, 2023
1 parent 5ebf445 commit 9fb1bb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):
result = res_op(skipna=skipna)
expected = exp_op(skipna=skipna)
if op_name in ["mean", "median"]:
expected = pd.Timestamp(expected, tz=ser.dtype.tz)
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype"
# has no attribute "tz"
tz = ser.dtype.tz # type: ignore[union-attr]
expected = pd.Timestamp(expected, tz=tz)
else:
expected = pd.Timedelta(expected)
tm.assert_almost_equal(result, expected)
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/extension/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):
exp_op = getattr(alt, op_name)
result = res_op(skipna=skipna)
expected = exp_op(skipna=skipna)
expected = Period._from_ordinal(int(expected), freq=ser.dtype.freq)
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype" has no
# attribute "freq"
freq = ser.dtype.freq # type: ignore[union-attr]
expected = Period._from_ordinal(int(expected), freq=freq)
tm.assert_almost_equal(result, expected)

else:
Expand Down

0 comments on commit 9fb1bb8

Please sign in to comment.