-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
TYPING: Module 'pytz' has no attribute 'FixedOffset' #28932
Conversation
@@ -4,11 +4,13 @@ | |||
from datetime import datetime, time | |||
import locale | |||
|
|||
# https://github.com/python/typeshed/pull/XXXX | |||
# error: Module 'pytz' has no attribute 'FixedOffset' |
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?
Out of curiosity do you know how hard it would be to do this in typeshed? I think they pull in latest type shed just before the release gets cut and from the few PRs I've done type shed turnaround is a few days at most. Might be able to solve directly at source instead of here |
This will be an issue with mypy 0.730, so a typeshed update won't fix straight away. |
i'll see what's required, submit a PR, then add the issue number here. if mypy bumps on conda in the meantime we could just merge as is. |
why don’t we just fix mypy at the current version? |
Similar to will’s idea, is there a clean fix upstream in pytz? |
brief discussion started here #27568 (comment) |
pytz is in typeshed, which ships with mypy. but missing FizedOffset. types in typeshed are created by the community. |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you just pytz.FixedOffset
to avoid the issues above?
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.
was just trying to use 1 ignore instead of 8..
$ mypy pandas
pandas\tests\indexes\datetimes\test_tools.py:270: error: Module has no attribute "FixedOffset"
pandas\tests\indexes\datetimes\test_tools.py:275: error: Module has no attribute "FixedOffset"
pandas\tests\indexes\datetimes\test_tools.py:281: error: Module has no attribute "FixedOffset"
pandas\tests\indexes\datetimes\test_tools.py:282: error: Module has no attribute "FixedOffset"
pandas\tests\indexes\datetimes\test_tools.py:290: error: Module has no attribute "FixedOffset"
pandas\tests\indexes\datetimes\test_tools.py:292: error: Module has no attribute "FixedOffset"
pandas\tests\indexes\datetimes\test_tools.py:2082: error: Module has no attribute "FixedOffset"
pandas\tests\indexes\datetimes\test_tools.py:2087: error: Module has no attribute "FixedOffset"
Found 8 errors in 1 file (checked 805 source files)
i'll close this. we should just pin mypy in ci. |
xref #28914 (comment)
@WillAyd we could use
from pytz import FixedOffset, ...
so that only a singletype: ignores
is required.