@@ -473,8 +473,7 @@ def __repr__(self):
473473 not_hashable = ([], UnhashableClass1 ())
474474 abc_hashable_not_really_hashable = (([],), UnhashableClass2 ())
475475 hashable_slice = HashableSlice (1 , 2 )
476- tuple_with_slice_1 = (slice (1 , 2 ), 3 )
477- tuple_with_slice_2 = ((1 , slice (1 , 2 )), "a" )
476+ tuple_with_slice = (slice (1 , 2 ), 3 )
478477
479478 for i in hashable :
480479 assert inference .is_hashable (i )
@@ -494,29 +493,15 @@ def __repr__(self):
494493 assert inference .is_hashable (hashable_slice , allow_slice = False )
495494
496495 if PY312 :
497- assert inference .is_hashable (slice (1 , 2 ))
498- assert inference .is_hashable (slice (1 , 2 ), allow_slice = True )
499- assert not inference .is_hashable (slice (1 , 2 ), allow_slice = False )
500-
501- assert inference .is_hashable (tuple_with_slice_1 )
502- assert inference .is_hashable (tuple_with_slice_1 , allow_slice = True )
503- assert not inference .is_hashable (tuple_with_slice_1 , allow_slice = False )
504-
505- assert inference .is_hashable (tuple_with_slice_2 )
506- assert inference .is_hashable (tuple_with_slice_2 , allow_slice = True )
507- assert not inference .is_hashable (tuple_with_slice_2 , allow_slice = False )
496+ for obj in [slice (1 , 2 ), tuple_with_slice ]:
497+ assert inference .is_hashable (obj )
498+ assert inference .is_hashable (obj , allow_slice = True )
499+ assert not inference .is_hashable (obj , allow_slice = False )
508500 else :
509- assert not inference .is_hashable (slice (1 , 2 ))
510- assert not inference .is_hashable (slice (1 , 2 ), allow_slice = True )
511- assert not inference .is_hashable (slice (1 , 2 ), allow_slice = False )
512-
513- assert not inference .is_hashable (tuple_with_slice_1 )
514- assert not inference .is_hashable (tuple_with_slice_1 , allow_slice = True )
515- assert not inference .is_hashable (tuple_with_slice_1 , allow_slice = False )
516-
517- assert not inference .is_hashable (tuple_with_slice_2 )
518- assert not inference .is_hashable (tuple_with_slice_2 , allow_slice = True )
519- assert not inference .is_hashable (tuple_with_slice_2 , allow_slice = False )
501+ for obj in [slice (1 , 2 ), tuple_with_slice ]:
502+ assert not inference .is_hashable (obj )
503+ assert not inference .is_hashable (obj , allow_slice = True )
504+ assert not inference .is_hashable (obj , allow_slice = False )
520505
521506 # numpy.array is no longer collections.abc.Hashable as of
522507 # https://github.com/numpy/numpy/pull/5326, just test
0 commit comments