Skip to content

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

Merged
merged 2 commits into from
May 1, 2019

Conversation

gwrome
Copy link
Contributor

@gwrome gwrome commented Apr 30, 2019

@@ -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
Copy link
Contributor Author

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 use typing.Pattern, which also works in 3.5. I've adopted that pattern in this PR, which corrected the mypy error

if PY36:
import typing
re_type = typing.re.Pattern
from typing import Pattern, Type
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've successfully tested from typing import Pattern, Type in 3.5.7, 3.6.8, and 3.7.3. I can't speak for anything before 3.5.7, but there's no problem importing after the most recent 3.5 micro version. I'll move the imports to the top and drop the else.

@codecov
Copy link

codecov bot commented May 1, 2019

Codecov Report

Merging #26252 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26252      +/-   ##
==========================================
- Coverage   91.98%   91.97%   -0.01%     
==========================================
  Files         175      175              
  Lines       52384    52384              
==========================================
- Hits        48184    48179       -5     
- Misses       4200     4205       +5
Flag Coverage Δ
#multiple 90.52% <100%> (ø) ⬆️
#single 40.72% <100%> (-0.14%) ⬇️
Impacted Files Coverage Δ
pandas/compat/__init__.py 92.85% <100%> (ø) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.61% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7eff627...dbcee29. Read the comment docs.

@codecov
Copy link

codecov bot commented May 1, 2019

Codecov Report

Merging #26252 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26252      +/-   ##
==========================================
- Coverage   91.98%   91.97%   -0.01%     
==========================================
  Files         175      175              
  Lines       52384    52383       -1     
==========================================
- Hits        48184    48179       -5     
- Misses       4200     4204       +4
Flag Coverage Δ
#multiple 90.52% <100%> (-0.01%) ⬇️
#single 40.72% <100%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/compat/__init__.py 94.87% <100%> (+2.01%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/base.py 97.98% <0%> (-0.22%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7eff627...f1ec34c. Read the comment docs.

@WillAyd WillAyd added the Typing type annotations, mypy/pyright type checking label May 1, 2019
@jreback jreback added this to the 0.25.0 milestone May 1, 2019
@jreback jreback merged commit 7fafb35 into pandas-dev:master May 1, 2019
@jreback
Copy link
Contributor

jreback commented May 1, 2019

thanks!

@gwrome gwrome deleted the blacklist-compat branch May 2, 2019 12:30
@topper-123 topper-123 mentioned this pull request May 3, 2019
1 task
gfyoung pushed a commit that referenced this pull request May 5, 2019
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.

Fix Type Annotation in pandas.compat
3 participants