-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYPING: Module 'pytz' has no attribute 'FixedOffset' #28932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,29 +270,29 @@ 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why don't you just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was just trying to use 1 ignore instead of 8..
|
||
], | ||
[ | ||
"%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)), | ||
], | ||
], | ||
[ | ||
"%Y-%m-%d %H:%M:%S %z", | ||
["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)')", | ||
), | ||
], | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is annoying. isort doesn't keep the comment next to the ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we try to fix upstream in isort?