Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

if self.left.is_unique and self.right.is_unique:
taken = self._intersection_unique(other)
elif (other.left.is_unique and other.right.is_unique and
Expand Down