33
44import contextlib
55from collections .abc import (
6- Callable ,
76 Collection ,
87 Iterable ,
98 Iterator ,
109 Mapping ,
1110 MutableMapping ,
12- Sequence ,
1311)
14- from types import UnionType
1512from typing import Protocol , cast , overload , override
1613
1714from sortedcontainers import SortedDict
@@ -138,8 +135,7 @@ def get(
138135 """
139136 if isinstance (key , Interval ):
140137 d = self [key ]
141- if default is not None :
142- d [key - d .domain ()] = default
138+ d [key - d .domain ()] = default
143139 return d
144140 else :
145141 try :
@@ -284,7 +280,7 @@ def update(
284280 self ,
285281 mapping_or_iterable : Mapping [object , V ]
286282 | Iterable [tuple [object , V ]]
287- | "IntervalDict[V]" ,
283+ | type [ "IntervalDict[V]" ] ,
288284 ):
289285 """
290286 Update current IntervalDict with provided values.
@@ -300,7 +296,7 @@ def update(
300296 else :
301297 data = mapping_or_iterable
302298
303- for i , v in data :
299+ for i , v in cast ( Collection [ tuple [ object , V ]], data ) :
304300 self [i ] = v
305301
306302 def combine (
@@ -414,7 +410,7 @@ def __getitem__(self, key: object | Interval) -> V | "IntervalDict[V]":
414410 raise KeyError (key )
415411
416412 @override
417- def __setitem__ (self , key : object | Interval , value : V ):
413+ def __setitem__ (self , key : object | Interval , value : V | None ):
418414 if isinstance (key , Interval ):
419415 interval = key
420416 else :
0 commit comments