diff --git a/pandas/tests/indexes/datetimes/test_tools.py b/pandas/tests/indexes/datetimes/test_tools.py index b6f25d45f136a..ff88c614cabd0 100644 --- a/pandas/tests/indexes/datetimes/test_tools.py +++ b/pandas/tests/indexes/datetimes/test_tools.py @@ -4,11 +4,14 @@ from datetime import datetime, time import locale +# https://github.com/python/typeshed/pull/XXXX +# error: Module 'pytz' has no attribute 'FixedOffset' from dateutil.parser import parse from dateutil.tz.tz import tzoffset import numpy as np import pytest import pytz +from pytz import FixedOffset # type:ignore from pandas._libs import tslib from pandas._libs.tslibs import iNaT, parsing @@ -267,19 +270,19 @@ def test_to_datetime_format_weeks(self, cache): [ "%Y-%m-%d %H:%M:%S%z", ["2010-01-01 12:00:00+0100"] * 2, - [pd.Timestamp("2010-01-01 12:00:00", tzinfo=pytz.FixedOffset(60))] * 2, + [pd.Timestamp("2010-01-01 12:00:00", tzinfo=FixedOffset(60))] * 2, ], [ "%Y-%m-%d %H:%M:%S %z", ["2010-01-01 12:00:00 +0100"] * 2, - [pd.Timestamp("2010-01-01 12:00:00", tzinfo=pytz.FixedOffset(60))] * 2, + [pd.Timestamp("2010-01-01 12:00:00", tzinfo=FixedOffset(60))] * 2, ], [ "%Y-%m-%d %H:%M:%S %z", ["2010-01-01 12:00:00 +0100", "2010-01-01 12:00:00 -0100"], [ - pd.Timestamp("2010-01-01 12:00:00", tzinfo=pytz.FixedOffset(60)), - pd.Timestamp("2010-01-01 12:00:00", tzinfo=pytz.FixedOffset(-60)), + pd.Timestamp("2010-01-01 12:00:00", tzinfo=FixedOffset(60)), + pd.Timestamp("2010-01-01 12:00:00", tzinfo=FixedOffset(-60)), ], ], [ @@ -287,9 +290,9 @@ def test_to_datetime_format_weeks(self, cache): ["2010-01-01 12:00:00 Z", "2010-01-01 12:00:00 Z"], [ pd.Timestamp( - "2010-01-01 12:00:00", tzinfo=pytz.FixedOffset(0) - ), # pytz coerces to UTC - pd.Timestamp("2010-01-01 12:00:00", tzinfo=pytz.FixedOffset(0)), + "2010-01-01 12:00:00", tzinfo=FixedOffset(0) + ), # pytz.FixedOffset coerces to UTC + pd.Timestamp("2010-01-01 12:00:00", tzinfo=FixedOffset(0)), ], ], ], @@ -931,8 +934,8 @@ def test_iso_8601_strings_same_offset_no_box(self): expected = np.array( [ - datetime(2018, 1, 4, 9, 1, tzinfo=pytz.FixedOffset(540)), - datetime(2018, 1, 4, 9, 2, tzinfo=pytz.FixedOffset(540)), + datetime(2018, 1, 4, 9, 1, tzinfo=FixedOffset(540)), + datetime(2018, 1, 4, 9, 2, tzinfo=FixedOffset(540)), ], dtype=object, ) @@ -1006,7 +1009,7 @@ def test_mixed_offsets_with_native_datetime_raises(self): def test_non_iso_strings_with_tz_offset(self): result = to_datetime(["March 1, 2018 12:00:00+0400"] * 2) expected = DatetimeIndex( - [datetime(2018, 3, 1, 12, tzinfo=pytz.FixedOffset(240))] * 2 + [datetime(2018, 3, 1, 12, tzinfo=FixedOffset(240))] * 2 ) tm.assert_index_equal(result, expected) @@ -2079,12 +2082,12 @@ def test_parsers_time(self): [ ( "2013-01-01 05:45+0545", - pytz.FixedOffset(345), + FixedOffset(345), "Timestamp('2013-01-01 05:45:00+0545', tz='pytz.FixedOffset(345)')", ), ( "2013-01-01 05:30+0530", - pytz.FixedOffset(330), + FixedOffset(330), "Timestamp('2013-01-01 05:30:00+0530', tz='pytz.FixedOffset(330)')", ), ],