-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix type annotation in pandas.compat #26252
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,11 +74,9 @@ def raise_with_traceback(exc, traceback=Ellipsis): | |
raise exc.with_traceback(traceback) | ||
|
||
|
||
# In Python 3.7, the private re._pattern_type is removed. | ||
# Python 3.5+ have typing.re.Pattern | ||
if PY36: | ||
import typing | ||
re_type = typing.re.Pattern | ||
from typing import Pattern, Type | ||
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. do these exist in 3.5? can u move this import to the top? 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. I tested the imports locally in 3.5.7, and they worked, so moving them shouldn't present a problem. 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. Type I think is from 3.5.2. We've used elsewhere so need to address at some point. Maybe vendoring, either dropping < 3.5.2 or vendoring that piece 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. Ignoring my previous comment for a second would we even need the Py36 condition or can we import all from the same space across versions? 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. I've successfully tested |
||
re_type = Pattern # type: Type[Pattern] | ||
else: | ||
re_type = type(re.compile('')) | ||
|
||
|
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.
I removed these comments because they're misleading.
typing.re.Pattern
is available in 3.5-3.7. It's been removed from the documentation as of 3.6, but it continues to be available. As of 3.6, the documented method is to usetyping.Pattern
, which also works in 3.5. I've adopted that pattern in this PR, which corrected the mypy error