2727import pandas .core .common as com
2828from pandas .core .construction import extract_array
2929import pandas .core .indexes .base as ibase
30- from pandas .core .indexes .base import Index , _index_shared_docs , maybe_extract_name
30+ from pandas .core .indexes .base import _index_shared_docs , maybe_extract_name
3131from pandas .core .indexes .numeric import Int64Index
3232from pandas .core .ops .common import unpack_zerodim_and_defer
3333
3434from pandas .io .formats .printing import pprint_thing
3535
36+ _empty_range = range (0 )
37+
3638
3739class RangeIndex (Int64Index ):
3840 """
@@ -130,15 +132,10 @@ def from_range(cls, data, name=None, dtype=None):
130132 return cls ._simple_new (data , dtype = dtype , name = name )
131133
132134 @classmethod
133- def _simple_new (cls , values , name = None , dtype = None ):
135+ def _simple_new (cls , values : range , name = None , dtype = None ) -> "RangeIndex" :
134136 result = object .__new__ (cls )
135137
136- # handle passed None, non-integers
137- if values is None :
138- # empty
139- values = range (0 , 0 , 1 )
140- elif not isinstance (values , range ):
141- return Index (values , dtype = dtype , name = name )
138+ assert isinstance (values , range )
142139
143140 result ._range = values
144141 result .name = name
@@ -482,7 +479,7 @@ def intersection(self, other, sort=False):
482479 return super ().intersection (other , sort = sort )
483480
484481 if not len (self ) or not len (other ):
485- return self ._simple_new (None )
482+ return self ._simple_new (_empty_range )
486483
487484 first = self ._range [::- 1 ] if self .step < 0 else self ._range
488485 second = other ._range [::- 1 ] if other .step < 0 else other ._range
@@ -492,7 +489,7 @@ def intersection(self, other, sort=False):
492489 int_low = max (first .start , second .start )
493490 int_high = min (first .stop , second .stop )
494491 if int_high <= int_low :
495- return self ._simple_new (None )
492+ return self ._simple_new (_empty_range )
496493
497494 # Method hint: linear Diophantine equation
498495 # solve intersection problem
@@ -502,7 +499,7 @@ def intersection(self, other, sort=False):
502499
503500 # check whether element sets intersect
504501 if (first .start - second .start ) % gcd :
505- return self ._simple_new (None )
502+ return self ._simple_new (_empty_range )
506503
507504 # calculate parameters for the RangeIndex describing the
508505 # intersection disregarding the lower bounds
0 commit comments