Skip to content
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

Closed

Conversation

simonjayhawkins
Copy link
Member

xref #28914 (comment)

@WillAyd we could use from pytz import FixedOffset, ... so that only a single type: ignores is required.

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Oct 11, 2019
@@ -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'
Copy link
Member Author

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

Copy link
Member

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?

@WillAyd
Copy link
Member

WillAyd commented Oct 12, 2019

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

@simonjayhawkins
Copy link
Member Author

This will be an issue with mypy 0.730, so a typeshed update won't fix straight away.

@simonjayhawkins
Copy link
Member Author

Out of curiosity do you know how hard it would be to do this in typeshed?

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.

@jreback
Copy link
Contributor

jreback commented Oct 12, 2019

why don’t we just fix mypy at the current version?

@jbrockmendel
Copy link
Member

Similar to will’s idea, is there a clean fix upstream in pytz?

@simonjayhawkins
Copy link
Member Author

why don’t we just fix mypy at the current version?

brief discussion started here #27568 (comment)

@simonjayhawkins
Copy link
Member Author

Similar to will’s idea, is there a clean fix upstream in pytz?

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,
Copy link
Contributor

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?

Copy link
Member Author

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)

@simonjayhawkins
Copy link
Member Author

i'll close this. we should just pin mypy in ci.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants