Skip to content

Add typing annotation to IntervalIndex.intersection #26870

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 5 commits into from
Jun 18, 2019

Conversation

makbigc
Copy link
Contributor

@makbigc makbigc commented Jun 15, 2019

Follow up #26225 (review)

@codecov
Copy link

codecov bot commented Jun 15, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26870      +/-   ##
==========================================
- Coverage   91.87%   91.86%   -0.01%     
==========================================
  Files         180      180              
  Lines       50716    50716              
==========================================
- Hits        46594    46590       -4     
- Misses       4122     4126       +4
Flag Coverage Δ
#multiple 90.45% <100%> (ø) ⬆️
#single 41.1% <100%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/interval.py 96.44% <100%> (ø) ⬆️
pandas/io/gbq.py 88.88% <0%> (-11.12%) ⬇️
pandas/core/frame.py 96.88% <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 d432f65...9f485c3. Read the comment docs.

@@ -1140,7 +1140,7 @@ def overlaps(self, other):

@Appender(_index_shared_docs['intersection'])
@SetopCheck(op_name='intersection')
def intersection(self, other, sort=False):
def intersection(self, other, sort: bool = False):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add typing on other? (and do this for all the intersection calls)?

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 did try something as follows in HEAD~1:

    def intersection(self,
                     other: IntervalIndex,
                     sort: bool = False
                     ) -> IntervalIndex:

But this will run into the NameError, i.e.,
NameError: name 'IntervalIndex' is not defined

Copy link
Contributor

Choose a reason for hiding this comment

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

use the string Intervalndex and this will work

@jreback jreback added the Typing type annotations, mypy/pyright type checking label Jun 16, 2019
@@ -1140,7 +1140,10 @@ def overlaps(self, other):

@Appender(_index_shared_docs['intersection'])
@SetopCheck(op_name='intersection')
def intersection(self, other, sort=False):
def intersection(self,
Copy link
Contributor

Choose a reason for hiding this comment

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

typing nitpick, we use single quotes on these annotations, otherwise lgtm. ping on green.

@WillAyd can we systematically check this?

@jreback jreback added this to the 0.25.0 milestone Jun 17, 2019
@jreback jreback merged commit 7375c73 into pandas-dev:master Jun 18, 2019
@jreback
Copy link
Contributor

jreback commented Jun 18, 2019

thanks @makbigc

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.

2 participants